Unverified Commit 09b7e413 authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Move some ops into v0 (#4138)

* Move some ops into v0

* namespace

* Make comments pretty

* Make comments pretty

* Merge fix
Co-authored-by: 's avatarRobert Kimball <robert.kimball@intel.com>
parent fbd99f34
......@@ -40,9 +40,12 @@ namespace ngraph
}
namespace op
{
namespace v0
{
class Parameter;
}
}
void traverse_nodes(const std::shared_ptr<const Function> p,
std::function<void(std::shared_ptr<Node>)> f,
......@@ -240,8 +243,8 @@ namespace ngraph
/// `body_replacement_map`, behavior is unspecified.
void replace_nodes(
const std::shared_ptr<Function>& f,
const std::unordered_map<std::shared_ptr<op::Parameter>, std::shared_ptr<op::Parameter>>&
parameter_replacement_map,
const std::unordered_map<std::shared_ptr<op::v0::Parameter>,
std::shared_ptr<op::v0::Parameter>>& parameter_replacement_map,
const std::unordered_map<std::shared_ptr<Node>, std::shared_ptr<Node>>&
body_replacement_map);
......@@ -400,7 +403,7 @@ namespace ngraph
// Assert that nodes in the function is colocated and return that placement
Placement get_colocated_function_placement(std::shared_ptr<Function> func);
std::pair<std::shared_ptr<op::Result>, std::shared_ptr<op::Parameter>>
std::pair<std::shared_ptr<op::Result>, std::shared_ptr<op::v0::Parameter>>
insert_result_parameter_split(const std::shared_ptr<Node>& src_node,
const std::shared_ptr<Node>& dst_node);
......
......@@ -60,11 +60,14 @@ namespace ngraph
namespace op
{
struct AutoBroadcastSpec;
class Constant;
namespace v0
{
class Result;
}
} // namespace op
using ResultVector = std::vector<std::shared_ptr<op::Result>>;
using ResultVector = std::vector<std::shared_ptr<op::v0::Result>>;
namespace autodiff
{
......
......@@ -421,6 +421,8 @@ void op::ScalarConstantLike::infer_element_type()
namespace ngraph
{
namespace op
{
namespace v0
{
template <>
void Constant::write_to_buffer<string>(const element::Type& /* target_type */,
......@@ -431,4 +433,5 @@ namespace ngraph
{
}
}
}
}
......@@ -29,6 +29,8 @@
namespace ngraph
{
namespace op
{
namespace v0
{
/// \brief Class for constants.
class NGRAPH_API Constant : public Op
......@@ -41,8 +43,8 @@ namespace ngraph
///
/// \param type The element type of the tensor constant.
/// \param shape The shape of the tensor constant.
/// \param values A vector of literals for initializing the tensor constant. The size
/// of values must match the size of the shape.
/// \param values A vector of literals for initializing the tensor constant. The
/// size of values must match the size of the shape.
template <typename T>
Constant(const element::Type& type, Shape shape, const std::vector<T>& values)
: m_element_type(type)
......@@ -85,8 +87,9 @@ namespace ngraph
Shape shape,
const std::vector<std::string>& values);
/// \brief Constructs a tensor constant with the same initialization value copied across
// the tensor. This constructor is to support deserialization of constants.
/// \brief Constructs a tensor constant with the same initialization value copied
/// across the tensor. This constructor is to support deserialization of
/// constants.
///
/// \param type The element type of the tensor constant.
/// \param shape The shape of the tensor constant.
......@@ -137,10 +140,10 @@ namespace ngraph
/// \param shape The shape of the tensor constant.
/// \param values A vector of values to use as the constant data.
template <typename T>
static std::shared_ptr<op::Constant>
static std::shared_ptr<op::v0::Constant>
create(const element::Type& type, Shape shape, const std::vector<T> values)
{
auto result = std::make_shared<op::Constant>(type, shape, values);
auto result = std::make_shared<op::v0::Constant>(type, shape, values);
result->validate_and_infer_types();
return result;
}
......@@ -151,10 +154,11 @@ namespace ngraph
/// \param shape The shape of the tensor constant.
/// \param values An initializer_list of values to use as the constant data.
template <typename T>
static std::shared_ptr<op::Constant>
static std::shared_ptr<op::v0::Constant>
create(const element::Type& type, Shape shape, std::initializer_list<T> values)
{
auto result = std::make_shared<op::Constant>(type, shape, std::vector<T>{values});
auto result =
std::make_shared<op::v0::Constant>(type, shape, std::vector<T>{values});
result->validate_and_infer_types();
return result;
}
......@@ -399,7 +403,7 @@ namespace ngraph
ScalarConstantLike() = default;
std::shared_ptr<Node> copy_with_new_args(const NodeVector& new_args) const override;
std::shared_ptr<op::Constant> as_constant() const;
std::shared_ptr<op::v0::Constant> as_constant() const;
protected:
void infer_element_type() override;
......@@ -407,4 +411,7 @@ namespace ngraph
double m_value;
};
}
using v0::Constant;
using v0::ScalarConstantLike;
}
}
......@@ -164,7 +164,7 @@ NGRAPH_OP(PRelu, ngraph::op::v0, 0)
NGRAPH_OP(PSROIPooling, ngraph::op::v0, 0)
NGRAPH_OP(Pad, ngraph::op::v0, 0)
NGRAPH_OP(Pad, ngraph::op::v1, 1)
NGRAPH_OP(Parameter, ngraph::op, 0)
NGRAPH_OP(Parameter, ngraph::op::v0, 0)
NGRAPH_OP(PartialSlice, ngraph::op::v0, 0)
NGRAPH_OP(PartialSliceBackprop, ngraph::op::v0, 0)
NGRAPH_OP(Passthrough, ngraph::op, 0)
......@@ -202,11 +202,11 @@ NGRAPH_OP(ReorgYolo, ngraph::op::v0, 0)
NGRAPH_OP(ReplaceSlice, ngraph::op::v0, 0)
NGRAPH_OP(Reshape, ngraph::op::v0, 0)
NGRAPH_OP(Reshape, ngraph::op::v1, 1)
NGRAPH_OP(Result, ngraph::op, 0)
NGRAPH_OP(Result, ngraph::op::v0, 0)
NGRAPH_OP(Reverse, ngraph::op::v0, 0)
NGRAPH_OP(Reverse, ngraph::op::v1, 1)
NGRAPH_OP(ReverseSequence, ngraph::op::v0, 0)
NGRAPH_OP(ScalarConstantLike, ngraph::op, 0)
NGRAPH_OP(ScalarConstantLike, ngraph::op::v0, 0)
NGRAPH_OP(ScaleShift, ngraph::op::v0, 0)
NGRAPH_OP(ScatterAdd, ngraph::op::v0, 0)
NGRAPH_OP(ScatterND, ngraph::op::v0, 0)
......
......@@ -22,12 +22,14 @@ namespace ngraph
{
class Function;
namespace op
{
namespace v0
{
/// \brief A function parameter.
///
/// Parameters are nodes that represent the arguments that will be passed to user-defined
/// functions. Function creation requires a sequence of parameters. Basic graph operations
/// do not need parameters attached to a function.
/// Parameters are nodes that represent the arguments that will be passed to
/// user-defined functions. Function creation requires a sequence of parameters.
/// Basic graph operations do not need parameters attached to a function.
class NGRAPH_API Parameter : public op::Op
{
protected:
......@@ -80,5 +82,7 @@ namespace ngraph
bool m_is_relevant_to_shapes;
};
}
using v0::Parameter;
}
using ParameterVector = std::vector<std::shared_ptr<op::Parameter>>;
}
......@@ -23,6 +23,8 @@
namespace ngraph
{
namespace op
{
namespace v0
{
class NGRAPH_API Result : public Op
{
......@@ -52,5 +54,8 @@ namespace ngraph
bool m_needs_default_layout{false};
};
}
using v0::Result;
}
using ResultVector = std::vector<std::shared_ptr<op::Result>>;
}
......@@ -19,6 +19,7 @@
#include <memory>
#include "ngraph/axis_set.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/op.hpp"
namespace ngraph
......
......@@ -115,7 +115,7 @@ NGRAPH_OP(OneHot, ngraph::op::v1)
NGRAPH_OP(PRelu, ngraph::op::v0)
NGRAPH_OP(PSROIPooling, ngraph::op::v0)
NGRAPH_OP(Pad, ngraph::op::v1)
NGRAPH_OP(Parameter, ngraph::op)
NGRAPH_OP(Parameter, ngraph::op::v0)
NGRAPH_OP(Power, ngraph::op::v1)
NGRAPH_OP(PriorBox, ngraph::op::v0)
NGRAPH_OP(PriorBoxClustered, ngraph::op::v0)
......@@ -131,7 +131,7 @@ NGRAPH_OP(ReduceProd, ngraph::op::v1)
NGRAPH_OP(ReduceSum, ngraph::op::v1)
NGRAPH_OP(RegionYolo, ngraph::op::v0)
NGRAPH_OP(Reshape, ngraph::op::v1)
NGRAPH_OP(Result, ngraph::op)
NGRAPH_OP(Result, ngraph::op::v0)
NGRAPH_OP(Reverse, ngraph::op::v1)
NGRAPH_OP(ReverseSequence, ngraph::op::v0)
NGRAPH_OP(RNNCell, ngraph::op::v0)
......
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