forked from mindspore-Ecosystem/mindspore
Delete deprecated old core api head files
This commit is contained in:
parent
24ce875ad0
commit
dba5866993
|
@ -281,8 +281,6 @@ if(PLATFORM_ARM64)
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||||
install(FILES ${ABSTRACT_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/abstract
|
install(FILES ${ABSTRACT_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/abstract
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||||
install(FILES ${API_IR_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/api/ir
|
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
|
||||||
install(FILES ${BASE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/base
|
install(FILES ${BASE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/base
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||||
install(FILES ${IR_DTYPE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/ir/dtype
|
install(FILES ${IR_DTYPE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/ir/dtype
|
||||||
|
@ -656,8 +654,6 @@ else()
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||||
install(FILES ${ABSTRACT_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/abstract
|
install(FILES ${ABSTRACT_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/abstract
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||||
install(FILES ${API_IR_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/api/ir
|
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
|
||||||
install(FILES ${BASE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/base
|
install(FILES ${BASE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/base
|
||||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||||
install(FILES ${IR_DTYPE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/ir/dtype
|
install(FILES ${IR_DTYPE_HEADER} DESTINATION ${CONVERTER_ROOT_DIR}/include/core/ir/dtype
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
|
* This is the C++ adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
|
||||||
*
|
*
|
||||||
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
* Copyright 2019-2022 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,7 +16,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define USE_DEPRECATED_API
|
|
||||||
#include "abstract/primitive_infer_map.h"
|
#include "abstract/primitive_infer_map.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
reviewers:
|
|
||||||
- zh_qh
|
|
||||||
- hwhewei
|
|
||||||
- xychow
|
|
||||||
- ginfung
|
|
||||||
- chenfei52
|
|
||||||
- zhangzhaoju
|
|
||||||
- lanzhineng
|
|
||||||
- lianliguang
|
|
||||||
- Margaret_wangrui
|
|
||||||
- irmo
|
|
||||||
- huangbingjian
|
|
||||||
- liangzhibo
|
|
|
@ -1,157 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT 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 MINDSPORE_CORE_API_IR_FUNC_GRAPH_H_
|
|
||||||
#define MINDSPORE_CORE_API_IR_FUNC_GRAPH_H_
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "utils/visible.h"
|
|
||||||
#include "api/ir/func_graph_manager.h"
|
|
||||||
|
|
||||||
namespace mindspore::deprecated::api {
|
|
||||||
/// \brief FuncGraph defines interface for a function graph.
|
|
||||||
class MS_CORE_API FuncGraph {
|
|
||||||
public:
|
|
||||||
/// \brief Constructor of FuncGraph.
|
|
||||||
FuncGraph() = default;
|
|
||||||
|
|
||||||
/// \brief Destructor of FuncGraph.
|
|
||||||
virtual ~FuncGraph() = default;
|
|
||||||
|
|
||||||
/// \brief Get the input parameters.
|
|
||||||
///
|
|
||||||
/// \return Input parameters of this graph.
|
|
||||||
virtual const std::vector<AnfNodePtr> get_inputs() const = 0;
|
|
||||||
|
|
||||||
/// \brief Get all parameters.
|
|
||||||
///
|
|
||||||
/// \return All parameters of this graph.
|
|
||||||
virtual const std::vector<AnfNodePtr> ¶meters() const = 0;
|
|
||||||
|
|
||||||
/// \brief Adds a parameter to this graph.
|
|
||||||
///
|
|
||||||
/// \param[in] p The parameter to be added.
|
|
||||||
virtual void add_parameter(const ParameterPtr &p) = 0;
|
|
||||||
|
|
||||||
/// \brief Adds a new parameter to this graph.
|
|
||||||
///
|
|
||||||
/// \return The new added parameter.
|
|
||||||
virtual ParameterPtr add_parameter() = 0;
|
|
||||||
|
|
||||||
/// \brief Get the output node.
|
|
||||||
///
|
|
||||||
/// \return The output node, nullptr if output not set.
|
|
||||||
virtual AnfNodePtr output() const = 0;
|
|
||||||
|
|
||||||
/// \brief Get the return CNode.
|
|
||||||
///
|
|
||||||
/// \return The return CNode, nullptr if no return node.
|
|
||||||
virtual CNodePtr get_return() const = 0;
|
|
||||||
|
|
||||||
/// \brief Set the output node.
|
|
||||||
///
|
|
||||||
/// \param[in] value The output node to be set.
|
|
||||||
/// \param[in] force_new_ret If true, a new return node is always created.
|
|
||||||
virtual void set_output(const AnfNodePtr &value, bool force_new_ret = false) = 0;
|
|
||||||
|
|
||||||
/// \brief Set the return node.
|
|
||||||
///
|
|
||||||
/// \param[in] cnode The return CNode to be set.
|
|
||||||
virtual void set_return(const CNodePtr &cnode) = 0;
|
|
||||||
|
|
||||||
/// \brief Creates a new CNode in this graph.
|
|
||||||
///
|
|
||||||
/// \param[in] inputs The input nodes of the new CNode.
|
|
||||||
///
|
|
||||||
/// \return The created CNode.
|
|
||||||
virtual CNodePtr NewCNode(const std::vector<AnfNodePtr> &inputs = std::vector<AnfNodePtr>()) = 0;
|
|
||||||
|
|
||||||
/// \brief Creates a new primitive CNode in this graph.
|
|
||||||
///
|
|
||||||
/// \param[in] primitive The primitive of the new CNode.
|
|
||||||
/// \param[in] prim_inputs The argument inputs of the primitive CNode.
|
|
||||||
///
|
|
||||||
/// \return The created primitive CNode.
|
|
||||||
virtual CNodePtr NewCNode(const PrimitivePtr &primitive, const std::vector<AnfNodePtr> &prim_inputs) = 0;
|
|
||||||
|
|
||||||
/// \brief Get all nodes in this graph.
|
|
||||||
///
|
|
||||||
/// \return All nodes in this graph.
|
|
||||||
virtual const AnfNodeSet &nodes() const = 0;
|
|
||||||
|
|
||||||
/// \brief Check whether an attribute is set for this graph.
|
|
||||||
///
|
|
||||||
/// \param[in] key The attribute key (name).
|
|
||||||
///
|
|
||||||
/// \return True if the attribute with the given key is set, false otherwise.
|
|
||||||
virtual bool has_attr(const std::string &key) const = 0;
|
|
||||||
|
|
||||||
/// \brief Get an attribute value by its key.
|
|
||||||
///
|
|
||||||
/// \param[in] key The attribute key (name).
|
|
||||||
///
|
|
||||||
/// \return The attribute value for the given key, nullptr if attribute not found.
|
|
||||||
virtual ValuePtr get_attr(const std::string &key) const = 0;
|
|
||||||
|
|
||||||
/// \brief Set an attribute value.
|
|
||||||
///
|
|
||||||
/// \param[in] key The attribute key (name).
|
|
||||||
/// \param[in] value The attribute value.
|
|
||||||
virtual void set_attr(const std::string &key, const ValuePtr &value) = 0;
|
|
||||||
|
|
||||||
/// \brief Get the manager for this graph.
|
|
||||||
///
|
|
||||||
/// \return The manager of this graph, nullptr if not set.
|
|
||||||
virtual FuncGraphManagerPtr get_manager() const = 0;
|
|
||||||
|
|
||||||
/// \brief Topological sort a graph from the given end node.
|
|
||||||
///
|
|
||||||
/// \param[in] node The end node of the graph to be sorted.
|
|
||||||
///
|
|
||||||
/// \return The sorted nodes.
|
|
||||||
static std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &node);
|
|
||||||
|
|
||||||
/// \brief Creates an empty function graph.
|
|
||||||
///
|
|
||||||
/// \return The created graph.
|
|
||||||
static FuncGraphPtr Create();
|
|
||||||
|
|
||||||
/// \brief Creates a value node that holds the given function graph.
|
|
||||||
///
|
|
||||||
/// \param[in] func_graph The given function graph.
|
|
||||||
//
|
|
||||||
/// \return The created value node that holds the given function graph.
|
|
||||||
static AnfNodePtr MakeValueNode(const FuncGraphPtr &func_graph);
|
|
||||||
|
|
||||||
/// \brief Get the function graph from the input node.
|
|
||||||
///
|
|
||||||
/// \param[in] input The input node.
|
|
||||||
//
|
|
||||||
/// \return The function graph if the input is value node that holds the graph, nullptr otherwise.
|
|
||||||
static FuncGraphPtr GetFuncGraphFromAnfNode(const AnfNodePtr &input);
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef USE_DEPRECATED_API
|
|
||||||
#define USE_DEPRECATED_API
|
|
||||||
namespace mindspore {
|
|
||||||
namespace api = deprecated::api;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} // namespace mindspore::deprecated::api
|
|
||||||
#endif // MINDSPORE_CORE_API_IR_FUNC_GRAPH_H_
|
|
|
@ -1,91 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT 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 MINDSPORE_CORE_API_IR_FUNC_GRAPH_MANAGER_H_
|
|
||||||
#define MINDSPORE_CORE_API_IR_FUNC_GRAPH_MANAGER_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "utils/visible.h"
|
|
||||||
#include "utils/compact_set.h"
|
|
||||||
#include "utils/hash_map.h"
|
|
||||||
#include "utils/hashing.h"
|
|
||||||
#include "ir/anf.h"
|
|
||||||
|
|
||||||
namespace mindspore::deprecated::api {
|
|
||||||
class FuncGraph;
|
|
||||||
using FuncGraphPtr = std::shared_ptr<FuncGraph>;
|
|
||||||
|
|
||||||
class FuncGraphManager;
|
|
||||||
using FuncGraphManagerPtr = std::shared_ptr<FuncGraphManager>;
|
|
||||||
|
|
||||||
using AnfNodeIndexSet = CompactSet<std::pair<AnfNodePtr, int>>;
|
|
||||||
using NodeUsersMap = mindspore::HashMap<AnfNodePtr, AnfNodeIndexSet, PointerHash<AnfNodePtr>>;
|
|
||||||
|
|
||||||
/// \brief FuncGraphManager defines interface for function graph management.
|
|
||||||
class MS_CORE_API FuncGraphManager {
|
|
||||||
public:
|
|
||||||
/// \brief Constructor of FuncGraphManager.
|
|
||||||
FuncGraphManager() = default;
|
|
||||||
|
|
||||||
/// \brief Destructor of FuncGraphManager.
|
|
||||||
virtual ~FuncGraphManager() = default;
|
|
||||||
|
|
||||||
/// \brief Replace an old node with a new node, related edges are all updated.
|
|
||||||
///
|
|
||||||
/// \param[in] old_node The old node to be replaced.
|
|
||||||
/// \param[in] new_node The new node that replace the old one.
|
|
||||||
///
|
|
||||||
/// \return True if the node is successfully replaced, false otherwise.
|
|
||||||
virtual bool Replace(const AnfNodePtr &old_node, const AnfNodePtr &new_node) = 0;
|
|
||||||
|
|
||||||
/// \brief Change an existed edge by replace its input node.
|
|
||||||
///
|
|
||||||
/// \param[in] node The output node of the edge.
|
|
||||||
/// \param[in] index The input index in output node.
|
|
||||||
/// \param[in] value The new input node of the edge.
|
|
||||||
virtual void SetEdge(const AnfNodePtr &node, int index, const AnfNodePtr &value) = 0;
|
|
||||||
|
|
||||||
/// \brief Adds a new edge between the given two nodes.
|
|
||||||
///
|
|
||||||
/// \param[in] node The output node of the edge.
|
|
||||||
/// \param[in] value The input node of the edge.
|
|
||||||
virtual void AddEdge(const AnfNodePtr &node, const AnfNodePtr &value) = 0;
|
|
||||||
|
|
||||||
/// \brief Get the node to users map.
|
|
||||||
///
|
|
||||||
/// \return The node to users map.
|
|
||||||
virtual const NodeUsersMap &node_users() const = 0;
|
|
||||||
|
|
||||||
/// \brief Manage the give function graph.
|
|
||||||
///
|
|
||||||
/// \param[in] func_graph The function graph to be managed.
|
|
||||||
/// \param[in] manage If true, the created manager will be set in graph.
|
|
||||||
///
|
|
||||||
/// \return The manager that manages the given function graph.
|
|
||||||
static FuncGraphManagerPtr Manage(const FuncGraphPtr &func_graph, bool manage = true);
|
|
||||||
};
|
|
||||||
} // namespace mindspore::deprecated::api
|
|
||||||
|
|
||||||
#ifndef USE_DEPRECATED_API
|
|
||||||
#define USE_DEPRECATED_API
|
|
||||||
namespace mindspore {
|
|
||||||
namespace api = deprecated::api;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // MINDSPORE_CORE_API_IR_FUNC_GRAPH_MANAGER_H_
|
|
|
@ -784,24 +784,10 @@ void FuncGraph::set_used_forward_nodes(const std::vector<AnfNodePtr> &used_forwa
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<AnfNodePtr> FuncGraph::TopoSort(const AnfNodePtr &node) { return mindspore::TopoSort(node); }
|
||||||
|
|
||||||
SeenNum NewFgSeenGeneration() {
|
SeenNum NewFgSeenGeneration() {
|
||||||
static SeenNum fg_seen_generation = 0;
|
static SeenNum fg_seen_generation = 0;
|
||||||
return ++fg_seen_generation;
|
return ++fg_seen_generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement TopoSort api.
|
|
||||||
std::vector<AnfNodePtr> api::FuncGraph::TopoSort(const AnfNodePtr &node) { return mindspore::TopoSort(node); }
|
|
||||||
|
|
||||||
// Create an api::FuncGraph instance.
|
|
||||||
api::FuncGraphPtr api::FuncGraph::Create() { return std::make_shared<mindspore::FuncGraph>(); }
|
|
||||||
|
|
||||||
AnfNodePtr api::FuncGraph::MakeValueNode(const api::FuncGraphPtr &func_graph) {
|
|
||||||
auto fg = std::dynamic_pointer_cast<mindspore::FuncGraph>(func_graph);
|
|
||||||
return NewValueNode(fg);
|
|
||||||
}
|
|
||||||
|
|
||||||
api::FuncGraphPtr api::FuncGraph::GetFuncGraphFromAnfNode(const AnfNodePtr &input) {
|
|
||||||
auto fg = GetValueNode<mindspore::FuncGraphPtr>(input);
|
|
||||||
return fg;
|
|
||||||
}
|
|
||||||
} // namespace mindspore
|
} // namespace mindspore
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "base/effect_info.h"
|
#include "base/effect_info.h"
|
||||||
#include "ir/func_graph_cloner.h"
|
#include "ir/func_graph_cloner.h"
|
||||||
#include "abstract/abstract_value.h"
|
#include "abstract/abstract_value.h"
|
||||||
#include "api/ir/func_graph.h"
|
|
||||||
#include "ir/func_graph_transform.h"
|
#include "ir/func_graph_transform.h"
|
||||||
#include "ir/func_graph_base.h"
|
#include "ir/func_graph_base.h"
|
||||||
#include "utils/visible.h"
|
#include "utils/visible.h"
|
||||||
|
@ -98,7 +97,7 @@ const char kFuncGraphFlagBackPropEntry[] = "BackPropEntry";
|
||||||
const char kFuncGraphFlagReAutoMonad[] = "ReAutoMonad";
|
const char kFuncGraphFlagReAutoMonad[] = "ReAutoMonad";
|
||||||
const char kFuncGraphFlagRecursive[] = "Recursive";
|
const char kFuncGraphFlagRecursive[] = "Recursive";
|
||||||
|
|
||||||
class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGraphBase, public EffectInfoHolder {
|
class MS_CORE_API FuncGraph : public FuncGraphBase, public EffectInfoHolder {
|
||||||
public:
|
public:
|
||||||
using Drawer = std::function<void(const std::string &, const FuncGraphPtr &)>;
|
using Drawer = std::function<void(const std::string &, const FuncGraphPtr &)>;
|
||||||
|
|
||||||
|
@ -114,16 +113,16 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
||||||
abstract::AbstractBasePtr ToAbstract() override;
|
abstract::AbstractBasePtr ToAbstract() override;
|
||||||
|
|
||||||
// get function graph inputs, but parameters
|
// get function graph inputs, but parameters
|
||||||
const std::vector<AnfNodePtr> get_inputs() const final;
|
const std::vector<AnfNodePtr> get_inputs() const;
|
||||||
// Return the graph's output, or nullptr if not yet deduced.
|
// Return the graph's output, or nullptr if not yet deduced.
|
||||||
AnfNodePtr output() const final;
|
AnfNodePtr output() const;
|
||||||
void set_output(const AnfNodePtr &value, bool force_new_ret = false);
|
void set_output(const AnfNodePtr &value, bool force_new_ret = false);
|
||||||
|
|
||||||
const std::vector<AnfNodePtr> ¶meters() const final { return parameters_; }
|
const std::vector<AnfNodePtr> ¶meters() const { return parameters_; }
|
||||||
// Append
|
// Append
|
||||||
ParameterPtr add_parameter() override;
|
virtual ParameterPtr add_parameter();
|
||||||
ParameterPtr add_parameter(NodeDebugInfoPtr &&debug_info);
|
ParameterPtr add_parameter(NodeDebugInfoPtr &&debug_info);
|
||||||
void add_parameter(const ParameterPtr &p) final;
|
void add_parameter(const ParameterPtr &p);
|
||||||
void append_parameter(const ParameterPtr &p) { parameters_.push_back(p); }
|
void append_parameter(const ParameterPtr &p) { parameters_.push_back(p); }
|
||||||
// Prepend
|
// Prepend
|
||||||
virtual ParameterPtr InsertFrontParameter();
|
virtual ParameterPtr InsertFrontParameter();
|
||||||
|
@ -136,8 +135,8 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
||||||
|
|
||||||
// Create a cnode with given inputs, bound to this graph.
|
// Create a cnode with given inputs, bound to this graph.
|
||||||
virtual CNodePtr NewCNode(std::vector<AnfNodePtr> &&inputs);
|
virtual CNodePtr NewCNode(std::vector<AnfNodePtr> &&inputs);
|
||||||
CNodePtr NewCNode(const std::vector<AnfNodePtr> &inputs = std::vector<AnfNodePtr>()) override;
|
virtual CNodePtr NewCNode(const std::vector<AnfNodePtr> &inputs = std::vector<AnfNodePtr>());
|
||||||
CNodePtr NewCNode(const PrimitivePtr &primitive, const std::vector<AnfNodePtr> &prim_inputs) final;
|
CNodePtr NewCNode(const PrimitivePtr &primitive, const std::vector<AnfNodePtr> &prim_inputs);
|
||||||
|
|
||||||
// Create a cnode with given inputs, bound to this graph and push back to order list.
|
// Create a cnode with given inputs, bound to this graph and push back to order list.
|
||||||
CNodePtr NewCNodeInOrder(std::vector<AnfNodePtr> &&inputs);
|
CNodePtr NewCNodeInOrder(std::vector<AnfNodePtr> &&inputs);
|
||||||
|
@ -194,24 +193,22 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
||||||
void set_flag(const std::string &key, bool flag) { attrs_[key] = MakeValue(flag); }
|
void set_flag(const std::string &key, bool flag) { attrs_[key] = MakeValue(flag); }
|
||||||
void erase_flag(const std::string &key) { (void)attrs_.erase(key); }
|
void erase_flag(const std::string &key) { (void)attrs_.erase(key); }
|
||||||
|
|
||||||
bool has_attr(const std::string &key) const final;
|
bool has_attr(const std::string &key) const;
|
||||||
ValuePtr get_attr(const std::string &key) const final;
|
ValuePtr get_attr(const std::string &key) const;
|
||||||
void set_attr(const std::string &key, const ValuePtr &value) final { attrs_[key] = value; }
|
void set_attr(const std::string &key, const ValuePtr &value) { attrs_[key] = value; }
|
||||||
|
|
||||||
mindspore::HashMap<std::string, FuncGraphTransform> &transforms() { return transforms_; }
|
mindspore::HashMap<std::string, FuncGraphTransform> &transforms() { return transforms_; }
|
||||||
void set_transforms(const mindspore::HashMap<std::string, FuncGraphTransform> &transforms) {
|
void set_transforms(const mindspore::HashMap<std::string, FuncGraphTransform> &transforms) {
|
||||||
transforms_ = transforms;
|
transforms_ = transforms;
|
||||||
}
|
}
|
||||||
|
|
||||||
CNodePtr get_return() const final { return return_; }
|
CNodePtr get_return() const { return return_; }
|
||||||
void set_return(const CNodePtr &cnode) final { return_ = cnode; }
|
void set_return(const CNodePtr &cnode) { return_ = cnode; }
|
||||||
const CNodePtr &return_node() const { return return_; }
|
const CNodePtr &return_node() const { return return_; }
|
||||||
|
|
||||||
FuncGraphManagerPtr manager() const { return manager_.lock(); }
|
FuncGraphManagerPtr manager() const { return manager_.lock(); }
|
||||||
void set_manager(const FuncGraphManagerPtr &m) { manager_ = std::weak_ptr<FuncGraphManager>(m); }
|
void set_manager(const FuncGraphManagerPtr &m) { manager_ = std::weak_ptr<FuncGraphManager>(m); }
|
||||||
|
|
||||||
deprecated::api::FuncGraphManagerPtr get_manager() const final { return manager_.lock(); }
|
|
||||||
|
|
||||||
std::string ToString() const override;
|
std::string ToString() const override;
|
||||||
GraphDebugInfoPtr debug_info();
|
GraphDebugInfoPtr debug_info();
|
||||||
void set_debug_info(const GraphDebugInfoPtr &info) {
|
void set_debug_info(const GraphDebugInfoPtr &info) {
|
||||||
|
@ -221,7 +218,7 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
||||||
this->debug_info_ = info;
|
this->debug_info_ = info;
|
||||||
}
|
}
|
||||||
// Get all nodes belonging to this func graph.
|
// Get all nodes belonging to this func graph.
|
||||||
const AnfNodeSet &nodes() const final;
|
const AnfNodeSet &nodes() const;
|
||||||
void CopyNodes(const FuncGraphPtr &source);
|
void CopyNodes(const FuncGraphPtr &source);
|
||||||
void ClearNodes();
|
void ClearNodes();
|
||||||
void AddNode(const AnfNodePtr &node);
|
void AddNode(const AnfNodePtr &node);
|
||||||
|
@ -371,6 +368,13 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
||||||
is_tensor_condition_branch_ = is_tensor_condition_branch;
|
is_tensor_condition_branch_ = is_tensor_condition_branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Topological sort a graph from the given end node.
|
||||||
|
///
|
||||||
|
/// \param[in] node The end node of the graph to be sorted.
|
||||||
|
///
|
||||||
|
/// \return The sorted nodes.
|
||||||
|
static std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Only used for func_graph manager to control resource free.
|
// Only used for func_graph manager to control resource free.
|
||||||
int attached_mng_cnt() const { return attached_mng_cnt_; }
|
int attached_mng_cnt() const { return attached_mng_cnt_; }
|
||||||
|
|
|
@ -203,10 +203,6 @@ FuncGraphManagerPtr Manage(FuncGraphPtr func_graph, bool manage) {
|
||||||
return Manage(func_graphs, manage);
|
return Manage(func_graphs, manage);
|
||||||
}
|
}
|
||||||
|
|
||||||
api::FuncGraphManagerPtr api::FuncGraphManager::Manage(const api::FuncGraphPtr &func_graph, bool manage) {
|
|
||||||
return mindspore::Manage(std::dynamic_pointer_cast<mindspore::FuncGraph>(func_graph), manage);
|
|
||||||
}
|
|
||||||
|
|
||||||
FuncGraphManager::FuncGraphManager(const std::vector<FuncGraphPtr> &roots, bool manage)
|
FuncGraphManager::FuncGraphManager(const std::vector<FuncGraphPtr> &roots, bool manage)
|
||||||
: roots_(roots), is_manage_(manage) {
|
: roots_(roots), is_manage_(manage) {
|
||||||
Reset();
|
Reset();
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
#include "utils/signal.h"
|
#include "utils/signal.h"
|
||||||
#include "utils/hash_map.h"
|
#include "utils/hash_map.h"
|
||||||
#include "utils/hash_set.h"
|
#include "utils/hash_set.h"
|
||||||
|
#include "utils/compact_set.h"
|
||||||
#include "utils/ordered_set.h"
|
#include "utils/ordered_set.h"
|
||||||
#include "utils/ordered_map.h"
|
#include "utils/ordered_map.h"
|
||||||
#include "ir/anf.h"
|
#include "ir/anf.h"
|
||||||
#include "ir/graph_utils.h"
|
#include "ir/graph_utils.h"
|
||||||
#include "utils/hashing.h"
|
#include "utils/hashing.h"
|
||||||
#include "base/base_ref.h"
|
#include "base/base_ref.h"
|
||||||
#include "api/ir/func_graph_manager.h"
|
|
||||||
|
|
||||||
namespace mindspore {
|
namespace mindspore {
|
||||||
namespace change {
|
namespace change {
|
||||||
|
@ -55,9 +55,9 @@ class FuncGraphTransaction;
|
||||||
class FuncGraphManager;
|
class FuncGraphManager;
|
||||||
using FuncGraphManagerPtr = std::shared_ptr<FuncGraphManager>;
|
using FuncGraphManagerPtr = std::shared_ptr<FuncGraphManager>;
|
||||||
|
|
||||||
using AnfNodeIndexSet = deprecated::api::AnfNodeIndexSet;
|
using AnfNodeIndexSet = CompactSet<std::pair<AnfNodePtr, int>>;
|
||||||
// NodeUsersMap, for node B input i use node A, it will be one item in map with key: A, and value: (B, i)
|
using NodeUsersMap = mindspore::HashMap<AnfNodePtr, AnfNodeIndexSet, PointerHash<AnfNodePtr>>;
|
||||||
using NodeUsersMap = deprecated::api::NodeUsersMap;
|
|
||||||
using FuncGraphSetPair = std::pair<FuncGraphPtr, FuncGraphSet>;
|
using FuncGraphSetPair = std::pair<FuncGraphPtr, FuncGraphSet>;
|
||||||
using FuncGraphSetPtr = std::shared_ptr<FuncGraphSet>;
|
using FuncGraphSetPtr = std::shared_ptr<FuncGraphSet>;
|
||||||
|
|
||||||
|
@ -278,8 +278,7 @@ class FuncGraphMetaFgPrimTotalComputer final : public DepComputer {
|
||||||
bool SeekMetaFgPrim(const FuncGraphPtr &fg, SeenNum seen_num);
|
bool SeekMetaFgPrim(const FuncGraphPtr &fg, SeenNum seen_num);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MS_CORE_API FuncGraphManager : public std::enable_shared_from_this<FuncGraphManager>,
|
class MS_CORE_API FuncGraphManager : public std::enable_shared_from_this<FuncGraphManager> {
|
||||||
public deprecated::api::FuncGraphManager {
|
|
||||||
public:
|
public:
|
||||||
explicit FuncGraphManager(const std::vector<FuncGraphPtr> &roots, bool manage = true);
|
explicit FuncGraphManager(const std::vector<FuncGraphPtr> &roots, bool manage = true);
|
||||||
virtual ~FuncGraphManager() {
|
virtual ~FuncGraphManager() {
|
||||||
|
@ -299,10 +298,10 @@ class MS_CORE_API FuncGraphManager : public std::enable_shared_from_this<FuncGra
|
||||||
void AddParameter(const FuncGraphPtr &fg, const AnfNodePtr ¶meter);
|
void AddParameter(const FuncGraphPtr &fg, const AnfNodePtr ¶meter);
|
||||||
void InsertFrontParameter(const FuncGraphPtr &fg, const AnfNodePtr ¶meter);
|
void InsertFrontParameter(const FuncGraphPtr &fg, const AnfNodePtr ¶meter);
|
||||||
void MaybeDropFuncGraphs(const FuncGraphSet &func_graphs, bool ignore_users = false);
|
void MaybeDropFuncGraphs(const FuncGraphSet &func_graphs, bool ignore_users = false);
|
||||||
bool Replace(const AnfNodePtr &old_node, const AnfNodePtr &new_node) final;
|
bool Replace(const AnfNodePtr &old_node, const AnfNodePtr &new_node);
|
||||||
bool Replace(const AnfNodePtr &old_node, const AnfNodePtr &new_node, const AnfNodePtr &mask_node);
|
bool Replace(const AnfNodePtr &old_node, const AnfNodePtr &new_node, const AnfNodePtr &mask_node);
|
||||||
void SetEdge(const AnfNodePtr &node, int index, const AnfNodePtr &value) final;
|
void SetEdge(const AnfNodePtr &node, int index, const AnfNodePtr &value);
|
||||||
void AddEdge(const AnfNodePtr &node, const AnfNodePtr &value) final;
|
void AddEdge(const AnfNodePtr &node, const AnfNodePtr &value);
|
||||||
void MoveAllCNodeDropGraph(const FuncGraphPtr &source, const FuncGraphPtr &target, const ScopePtr &scope);
|
void MoveAllCNodeDropGraph(const FuncGraphPtr &source, const FuncGraphPtr &target, const ScopePtr &scope);
|
||||||
|
|
||||||
FuncGraphTransaction Transact();
|
FuncGraphTransaction Transact();
|
||||||
|
@ -318,7 +317,7 @@ class MS_CORE_API FuncGraphManager : public std::enable_shared_from_this<FuncGra
|
||||||
|
|
||||||
NodeUsersMap &node_users() { return node_users_; }
|
NodeUsersMap &node_users() { return node_users_; }
|
||||||
|
|
||||||
const NodeUsersMap &node_users() const final { return node_users_; }
|
const NodeUsersMap &node_users() const { return node_users_; }
|
||||||
|
|
||||||
FVTotalMap &free_variables_total() const;
|
FVTotalMap &free_variables_total() const;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "mindapi/ir/func_graph.h"
|
#include "mindapi/ir/func_graph.h"
|
||||||
#include "mindapi/src/helper.h"
|
#include "mindapi/src/helper.h"
|
||||||
#define USE_DEPRECATED_API
|
|
||||||
#include "ir/anf.h"
|
#include "ir/anf.h"
|
||||||
#include "ir/value.h"
|
#include "ir/value.h"
|
||||||
#include "ir/func_graph.h"
|
#include "ir/func_graph.h"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
* Copyright 2021-2022 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include "mindapi/ir/utils.h"
|
#include "mindapi/ir/utils.h"
|
||||||
#include "mindapi/src/helper.h"
|
#include "mindapi/src/helper.h"
|
||||||
#define USE_DEPRECATED_API
|
|
||||||
#include "ir/anf.h"
|
#include "ir/anf.h"
|
||||||
#include "ir/value.h"
|
#include "ir/value.h"
|
||||||
#include "ir/func_graph_cloner.h"
|
#include "ir/func_graph_cloner.h"
|
||||||
|
|
|
@ -12,10 +12,6 @@ set(ABSTRACT_HEADER
|
||||||
${CORE_DIR}/abstract/primitive_infer_map.h
|
${CORE_DIR}/abstract/primitive_infer_map.h
|
||||||
${CORE_DIR}/abstract/utils.h
|
${CORE_DIR}/abstract/utils.h
|
||||||
)
|
)
|
||||||
set(API_IR_HEADER
|
|
||||||
${CORE_DIR}/api/ir/func_graph.h
|
|
||||||
${CORE_DIR}/api/ir/func_graph_manager.h
|
|
||||||
)
|
|
||||||
file(GLOB MINDAPI_BASE_HEADER ${CORE_DIR}/mindapi/base/*.h)
|
file(GLOB MINDAPI_BASE_HEADER ${CORE_DIR}/mindapi/base/*.h)
|
||||||
file(GLOB MINDAPI_IR_HEADER ${CORE_DIR}/mindapi/ir/*.h)
|
file(GLOB MINDAPI_IR_HEADER ${CORE_DIR}/mindapi/ir/*.h)
|
||||||
set(BASE_HEADER
|
set(BASE_HEADER
|
||||||
|
|
Loading…
Reference in New Issue