Skip to content

Commit

Permalink
added methods for parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sadolini committed Jan 12, 2021
1 parent ba08abb commit 2c43725
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ngraph/core/include/ngraph/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ namespace ngraph
/// \param result Result node to delete
void remove_result(const std::shared_ptr<op::Result>& result);

/// \brief Add new Parameter nodes to the list. Method doesn't validate graph, it should be
/// done manually after all changes.
/// \param params new Parameter nodes
void add_parameters(const ParameterVector& params);

/// \brief Delete Parameter node from the list of parameters. Method will not delete node from
/// graph.
/// \param param Parameter node to delete
void remove_parameter(const std::shared_ptr<op::Parameter>& param);

private:
Function(const Function&) = delete;
Function(const Function&&) = delete;
Expand Down
14 changes: 14 additions & 0 deletions ngraph/core/src/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,18 @@ void Function::remove_result(const std::shared_ptr<op::Result>& result)
m_results.end());
}

void Function::add_parameters(const ParameterVector& params)
{
m_parameters.insert(m_parameters.end(), params.begin(), params.end());
}

void Function::remove_parameter(const std::shared_ptr<op::Parameter>& param)
{
m_parameters.erase(
std::remove_if(m_parameters.begin(),
m_parameters.end(),
[&param](std::shared_ptr<op::v0::Parameter>& r) { return r == param; }),
m_parameters.end());
}

constexpr DiscreteTypeInfo AttributeAdapter<shared_ptr<Function>>::type_info;

0 comments on commit 2c43725

Please sign in to comment.