diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ee4a9e9d03d6c4a7aa9d0574bd22b2fc8206620..f3b016295f20f8d0d32c13a96ba602ec80b62618 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ if (ENABLE_METADEF_UT OR ENABLE_METADEF_ST OR ENABLE_BENCHMARK) add_subdirectory(tests) endif() -install(TARGETS exe_graph error_manager graph graph_base flow_graph register rt2_registry_static metadef_headers +install(TARGETS exe_graph error_manager graph graph_base expression ascend_ir flow_graph register rt2_registry_static metadef_headers EXPORT metadef-targets LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL COMPONENT opensdk ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL COMPONENT opensdk @@ -205,6 +205,8 @@ if (ENABLE_OPEN_SRC) exe_graph graph graph_base + expression + ascend_ir register rt2_registry_static LIBRARY DESTINATION ${ARCH_LINX_PATH}/lib64 OPTIONAL COMPONENT packages EXCLUDE_FROM_ALL diff --git a/graph/CMakeLists.txt b/graph/CMakeLists.txt index 3ad14e0081f3f940d82f74ee47545f44cde1a181..25c684f42ff4364a71d31979f202dd84bbb10a3d 100644 --- a/graph/CMakeLists.txt +++ b/graph/CMakeLists.txt @@ -21,6 +21,7 @@ set(GRAPH_BASE_SOURCE_LIST "attr/attr_store.cc" "attr/attr_group_base.cc" "attr/attr_group_symbolic_desc_attr.cc" + "attr/attr_group_shape_env_attr.cc" "buffer/buffer.cc" "utils/aligned_ptr.cc" "normal_graph/compute_graph.cc" @@ -353,6 +354,7 @@ else() slog json platform + expression -Wl,--as-needed $<$>:-lrt> -ldl diff --git a/graph/ascend_ir/utils/cg_utils.cc b/graph/ascend_ir/utils/cg_utils.cc index 0c7be37098206cc1dec86b73b70b16b6fa0be98e..6b82f741febca8be6b924ad0df2a882e0cd7aec6 100644 --- a/graph/ascend_ir/utils/cg_utils.cc +++ b/graph/ascend_ir/utils/cg_utils.cc @@ -7,9 +7,9 @@ * See LICENSE in the root of the software repository for the full text of the License. * ===================================================================================================================*/ -#include "cg_utils.h" -#include "node_utils_ex.h" -#include "graph_utils_ex.h" +#include "graph/utils/cg_utils.h" +#include "graph/utils/node_utils_ex.h" +#include "graph/utils/graph_utils_ex.h" #include "ascend_ir/core/ascend_ir_impl.h" namespace ge { namespace ascir { diff --git a/graph/attr/attr_group_shape_env_attr.cc b/graph/attr/attr_group_shape_env_attr.cc new file mode 100644 index 0000000000000000000000000000000000000000..608bcd2d7a17d5832dc52122fcb705138a226f77 --- /dev/null +++ b/graph/attr/attr_group_shape_env_attr.cc @@ -0,0 +1,64 @@ +/* Copyright (c) 2024 Huawei Technologies Co., Ltd. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + * ===================================================================================================================*/ + +#include "attribute_group/attr_group_shape_env.h" +#include "common/checker.h" +#include "proto/ge_ir.pb.h" + +namespace ge { + +graphStatus ShapeEnvAttr::Serialize(proto::AttrGroupDef &attr_group_def) { + auto shape_env_group = attr_group_def.mutable_shape_env_attr_group(); + GE_ASSERT_NOTNULL(shape_env_group); + shape_env_group->clear_symbol_to_value(); + auto symbol_to_value_def = shape_env_group->mutable_symbol_to_value(); + GE_ASSERT_NOTNULL(symbol_to_value_def); + for (const auto &iter : symbol_to_value) { + symbol_to_value_def->insert({iter.first.Str().get(), iter.second}); + } + auto value_to_symbol_def = shape_env_group->mutable_value_to_symbol(); + GE_ASSERT_NOTNULL(value_to_symbol_def); + for (const auto &iter : value_to_symbol) { + value_to_symbol_def->insert({iter.first, iter.second.Str().get()}); + } + auto symbol_to_source_def = shape_env_group->mutable_symbol_to_source(); + GE_ASSERT_NOTNULL(symbol_to_source_def); + for (const auto &iter : symbol_to_source) { + proto::InputSourceDef input_source_def; + input_source_def.set_input_data_idx(iter.second.GetInputDataIdx()); + input_source_def.set_dim_idx(iter.second.GetDimIdx()); + symbol_to_source_def->insert({iter.first.Str().get(), input_source_def}); + } + return GRAPH_SUCCESS; +} + +graphStatus ShapeEnvAttr::Deserialize(const proto::AttrGroupDef &attr_group_def) { + const auto& shape_env_attr_group = attr_group_def.shape_env_attr_group(); + symbol_to_value.clear(); + for (const auto &iter : shape_env_attr_group.symbol_to_value()) { + symbol_to_value.emplace(std::make_pair(Symbol(iter.first), iter.second)); + } + value_to_symbol.clear(); + for (const auto &iter : shape_env_attr_group.value_to_symbol()) { + value_to_symbol.emplace(std::make_pair(iter.first, Symbol(iter.second))); + } + symbol_to_source.clear(); + for (const auto &iter : shape_env_attr_group.symbol_to_source()) { + symbol_to_source.emplace(std::make_pair(Symbol(iter.first), + InputSource(iter.second.input_data_idx, iter.second.dim_idx))); + } + return GRAPH_SUCCESS; +} + +AttrGroupsBase *ShapeEnvAttr::CreateNew() { + auto new_attr = new (std::nothrow) ShapeEnvAttr(); + GE_ASSERT_NOTNULL(new_attr); + return new_attr; +} +} // namespace ge \ No newline at end of file diff --git a/inc/graph/attribute_group/attr_group_shape_env.h b/inc/graph/attribute_group/attr_group_shape_env.h index b0e5e88e6b49909810aaacd71c5d18f6b026b58b..45215a196c7f90e70db42c72239a082e15baf269 100644 --- a/inc/graph/attribute_group/attr_group_shape_env.h +++ b/inc/graph/attribute_group/attr_group_shape_env.h @@ -54,19 +54,9 @@ class ShapeEnvAttr : public AttrGroupsBase { ShapeEnvAttr() = default; ~ShapeEnvAttr() override = default; - graphStatus Serialize(proto::AttrGroupDef &attr_group_def) override { - GELOGW("ShapeEnvAttr::Serialize not support"); - return GRAPH_SUCCESS; - } - graphStatus Deserialize(const proto::AttrGroupDef &attr_group_def) override { - GELOGW("ShapeEnvAttr::Deserialize not support"); - return GRAPH_SUCCESS; - } - AttrGroupsBase *CreateNew() override { - auto new_attr = new (std::nothrow) ShapeEnvAttr(); - GE_ASSERT_NOTNULL(new_attr); - return new_attr; - } + graphStatus Serialize(proto::AttrGroupDef &attr_group_def); + graphStatus Deserialize(const proto::AttrGroupDef &attr_group_def); + AttrGroupsBase *CreateNew() override; std::unordered_map symbol_to_value; std::unordered_map value_to_symbol; std::unordered_map symbol_to_source; diff --git a/proto/ge_ir.proto b/proto/ge_ir.proto index 054a86601eba9d4a5a52768e63b69ee03fd25e23..a3a13a38ce1f1a098330c0a6dfe91a1debc14474 100644 --- a/proto/ge_ir.proto +++ b/proto/ge_ir.proto @@ -148,10 +148,22 @@ message TensorDescAttrGroupsDef { repeated string symbolic_value = 3; // symbolic value } +message InputSourceDef { + int32 input_data_idx = 1; + int64 dim_idx = 2; +} + +message ShapeEnvAttrGroupsDef { + map symbol_to_value = 1; + map value_to_symbol = 2; + map symbol_to_source = 3; +} + message AttrGroupDef { oneof attr_group { AscendIROpAttrGroupsDef op_attr_group = 2; TensorDescAttrGroupsDef tensor_attr_group = 3; + ShapeEnvAttrGroupsDef shape_env_attr_group = 4; } }