Commit 304f1219 authored by Scott Cyphers's avatar Scott Cyphers

style

parent 966d2cc2
...@@ -21,7 +21,6 @@ namespace ngraph ...@@ -21,7 +21,6 @@ namespace ngraph
/// Base error for ngraph runtime errors. /// Base error for ngraph runtime errors.
struct ngraph_error : std::runtime_error struct ngraph_error : std::runtime_error
{ {
explicit ngraph_error(const std::string& what_arg) explicit ngraph_error(const std::string& what_arg)
: std::runtime_error(what_arg) : std::runtime_error(what_arg)
{ {
......
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
namespace ngraph namespace ngraph
{ {
/** /**
** A user-defined function. ** A user-defined function.
**/ **/
class Function class Function
{ {
public: public:
Function(const Node::ptr& result, const std::vector<std::shared_ptr<Parameter>>& parameters); Function(const Node::ptr& result,
const std::vector<std::shared_ptr<Parameter>>& parameters);
Node::ptr result() { return m_result; } Node::ptr result() { return m_result; }
...@@ -44,7 +44,11 @@ namespace ngraph ...@@ -44,7 +44,11 @@ namespace ngraph
namespace op namespace op
{ {
std::shared_ptr<Function> function(const Node::ptr& result, const std::initializer_list<std::shared_ptr<Parameter>>& parameters); std::shared_ptr<Function>
std::shared_ptr<Function> function(const Node::ptr& result, const std::vector<std::shared_ptr<Parameter>>& parameters); function(const Node::ptr& result,
const std::initializer_list<std::shared_ptr<Parameter>>& parameters);
std::shared_ptr<Function>
function(const Node::ptr& result,
const std::vector<std::shared_ptr<Parameter>>& parameters);
} }
} }
...@@ -69,7 +69,10 @@ namespace ngraph ...@@ -69,7 +69,10 @@ namespace ngraph
** will be used by the pattern matcher when comparing a pattern ** will be used by the pattern matcher when comparing a pattern
** graph against the graph. ** graph against the graph.
**/ **/
bool is_same_op_type(const Node::ptr& node) const { return typeid(*this) == typeid(*node.get()); } bool is_same_op_type(const Node::ptr& node) const
{
return typeid(*this) == typeid(*node.get());
}
protected: protected:
std::vector<Node::ptr> m_arguments; std::vector<Node::ptr> m_arguments;
......
...@@ -73,7 +73,6 @@ namespace ngraph ...@@ -73,7 +73,6 @@ namespace ngraph
class Op : public Node class Op : public Node
{ {
public: public:
Op(const std::vector<Node::ptr>& arguments) Op(const std::vector<Node::ptr>& arguments)
: Node(arguments, nullptr) : Node(arguments, nullptr)
{ {
...@@ -86,8 +85,8 @@ namespace ngraph ...@@ -86,8 +85,8 @@ namespace ngraph
**/ **/
class FunctionOp : public Op class FunctionOp : public Op
{ {
virtual std::string description() const override { return "FunctionOp"; } virtual std::string description() const override { return "FunctionOp"; }
protected: protected:
Node::ptr m_function; Node::ptr m_function;
}; };
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
namespace ngraph namespace ngraph
{ {
class Function; class Function;
/** /**
...@@ -30,6 +29,7 @@ namespace ngraph ...@@ -30,6 +29,7 @@ namespace ngraph
class Parameter : public Node class Parameter : public Node
{ {
friend class Function; friend class Function;
protected: protected:
// Called by the Function constructor to associate this parameter with the function. // Called by the Function constructor to associate this parameter with the function.
// It is an error to try to associate a parameter with more than one function. // It is an error to try to associate a parameter with more than one function.
...@@ -50,8 +50,9 @@ namespace ngraph ...@@ -50,8 +50,9 @@ namespace ngraph
namespace op namespace op
{ {
/// Factory for frameworks /// Factory for frameworks
std::shared_ptr<ngraph::Parameter> parameter(const ValueType::ptr& value_type=nullptr); std::shared_ptr<ngraph::Parameter> parameter(const ValueType::ptr& value_type = nullptr);
/// Convenience factory for tests /// Convenience factory for tests
std::shared_ptr<ngraph::Parameter> parameter(const ngraph::element::Type element_type, const Shape& shape); std::shared_ptr<ngraph::Parameter> parameter(const ngraph::element::Type element_type,
const Shape& shape);
} }
} }
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
using namespace std; using namespace std;
using namespace ngraph; using namespace ngraph;
Function::Function(const Node::ptr& result, const std::vector<std::shared_ptr<ngraph::Parameter>>& parameters) Function::Function(const Node::ptr& result,
const std::vector<std::shared_ptr<ngraph::Parameter>>& parameters)
: m_result(result) : m_result(result)
, m_parameters(parameters) , m_parameters(parameters)
, m_name("Function") , m_name("Function")
...@@ -29,12 +30,14 @@ Function::Function(const Node::ptr& result, const std::vector<std::shared_ptr<ng ...@@ -29,12 +30,14 @@ Function::Function(const Node::ptr& result, const std::vector<std::shared_ptr<ng
} }
} }
shared_ptr<Function> ngraph::op::function(const Node::ptr& result, const initializer_list<shared_ptr<Parameter>>& parameters) shared_ptr<Function> ngraph::op::function(const Node::ptr& result,
const initializer_list<shared_ptr<Parameter>>& parameters)
{ {
return make_shared<Function>(result, parameters); return make_shared<Function>(result, parameters);
} }
shared_ptr<Function> ngraph::op::function(const Node::ptr& result, const vector<shared_ptr<Parameter>>& parameters) shared_ptr<Function> ngraph::op::function(const Node::ptr& result,
const vector<shared_ptr<Parameter>>& parameters)
{ {
return make_shared<Function>(result, parameters); return make_shared<Function>(result, parameters);
} }
...@@ -26,23 +26,23 @@ Parameter::Parameter(const ValueType::ptr& value_type) ...@@ -26,23 +26,23 @@ Parameter::Parameter(const ValueType::ptr& value_type)
void Parameter::assign_function(Function* function, size_t index) void Parameter::assign_function(Function* function, size_t index)
{ {
if (nullptr != m_function){ if (nullptr != m_function)
{
throw ngraph_error("Re-assigning function to a parameter."); throw ngraph_error("Re-assigning function to a parameter.");
} }
m_function = function; m_function = function;
m_index = index; m_index = index;
} }
void Parameter::propagate_types() void Parameter::propagate_types() {}
{
}
shared_ptr<Parameter> ngraph::op::parameter(const ValueType::ptr& value_type) shared_ptr<Parameter> ngraph::op::parameter(const ValueType::ptr& value_type)
{ {
return make_shared<Parameter>(value_type); return make_shared<Parameter>(value_type);
} }
shared_ptr<Parameter> ngraph::op::parameter(const ngraph::element::Type element_type, const Shape& shape) shared_ptr<Parameter> ngraph::op::parameter(const ngraph::element::Type element_type,
const Shape& shape)
{ {
return make_shared<Parameter>(make_shared<TensorViewType>(element_type, shape)); return make_shared<Parameter>(make_shared<TensorViewType>(element_type, shape));
} }
...@@ -32,6 +32,7 @@ TEST(build_graph, build_simple) ...@@ -32,6 +32,7 @@ TEST(build_graph, build_simple)
ASSERT_EQ(dot->arguments()[1], arg0); ASSERT_EQ(dot->arguments()[1], arg0);
auto cluster_0 = op::function(dot, {arg0, arg1, arg2, arg3}); auto cluster_0 = op::function(dot, {arg0, arg1, arg2, arg3});
ASSERT_EQ(cluster_0->result(), dot); ASSERT_EQ(cluster_0->result(), dot);
} }
...@@ -72,8 +73,4 @@ TEST(build_graph, node_comparison) ...@@ -72,8 +73,4 @@ TEST(build_graph, node_comparison)
} }
// Check argument inverses // Check argument inverses
TEST(build_graph, arg_inverse) TEST(build_graph, arg_inverse) {}
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment