Skip to content

Commit

Permalink
Moved operations D-F to ov namespace (openvinotoolkit#7341)
Browse files Browse the repository at this point in the history
* Moved ngraph::Node to ov namespace

* Fixed code style

* Fixed VPU

* Fixed GNA

* Fixed tests

* Added aliases for backward compatibility

* Fix clDNN

* Try to fix build

* Fixed comment

* Renamed RTTI macros

* Moved op utils to ov namespace

* Fixed ngraph library build

* Fixed unit-tests

* Changed src folder

* Fixed recurrent_sequence

* Changed low latency

* Fixed serialize

* Fixed ieFuncTests

* Try to fix windows

* Remove custom operator<< from tests

* Fixed build

* Moved operations from A to ov namespace

* Moved operations from B and C to ov namespace

* Moved operations D-F to ov namespace

* Update ngraph/core/src/op/embeddingbag_offsets_sum.cpp

Co-authored-by: Katarzyna Mitrus <[email protected]>

* Update ngraph/core/src/op/embeddingbag_packedsum.cpp

Co-authored-by: Katarzyna Mitrus <[email protected]>

Co-authored-by: Ilya Lavrenov <[email protected]>
Co-authored-by: Katarzyna Mitrus <[email protected]>
  • Loading branch information
3 people authored and akuporos committed Sep 6, 2021
1 parent 8401fd9 commit 726e873
Show file tree
Hide file tree
Showing 73 changed files with 1,580 additions and 1,165 deletions.
158 changes: 3 additions & 155 deletions ngraph/core/include/ngraph/op/deformable_convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,168 +8,16 @@
#include "ngraph/op/op.hpp"
#include "ngraph/op/util/attr_types.hpp"
#include "ngraph/op/util/deformable_convolution_base.hpp"
#include "openvino/op/deformable_convolution.hpp"

namespace ngraph {
namespace op {
namespace v1 {
/// \brief DeformableConvolution operation.
class NGRAPH_API DeformableConvolution : public op::util::DeformableConvolutionBase {
public:
NGRAPH_RTTI_DECLARATION;

/// \brief Constructs a conversion operation.
DeformableConvolution() = default;
/// \brief Constructs a conversion operation.
///
/// \param arg Node that produces the input tensor.
/// \param offsets Node producing the deformable values tensor.
/// \param filters Node producing the filters(kernels) tensor with OIZYX
/// layout.
/// \param strides Convolution strides.
/// \param pads_begin Amount of padding to be added to the beginning along
/// each axis. For example in case of a 2D input the value
/// of (1, 2) means that 1 element will be added to the
/// top and 2 elements to the left.
/// \param pads_end Amount of padding to be added to the end along each
/// axis.
/// \param dilations The distance in width and height between the weights
/// in the filters tensor.
/// \param auto_pad Specifies how the automatic calculation of padding
/// should be done.
/// \param group The number of groups which both output and input
/// should be split into.
/// \param deformable_group The number of groups which deformable values and
/// output should be split into along the channel axis.
DeformableConvolution(const Output<Node>& arg,
const Output<Node>& offsets,
const Output<Node>& filters,
const Strides& strides,
const CoordinateDiff& pads_begin,
const CoordinateDiff& pads_end,
const Strides& dilations,
const PadType& auto_pad = PadType::EXPLICIT,
const int64_t group = 1,
const int64_t deformable_group = 1);

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
};
using ov::op::v1::DeformableConvolution;
} // namespace v1

namespace v8 {
class NGRAPH_API DeformableConvolution : public op::util::DeformableConvolutionBase {
public:
NGRAPH_RTTI_DECLARATION;

/// \brief Constructs a conversion operation.
DeformableConvolution() = default;
/// \brief Constructs a conversion operation.
///
/// \param arg Node that produces the input tensor.
/// \param offsets Node producing the deformable values tensor.
/// \param filters Node producing the filters(kernels) tensor with OIZYX
/// layout.
/// \param strides Convolution strides.
/// \param pads_begin Amount of padding to be added to the beginning along
/// each axis. For example in case of a 2D input the value
/// of (1, 2) means that 1 element will be added to the
/// top and 2 elements to the left.
/// \param pads_end Amount of padding to be added to the end along each
/// axis.
/// \param dilations The distance in width and height between the weights
/// in the filters tensor.
/// \param auto_pad Specifies how the automatic calculation of padding
/// should be done.
/// \param group The number of groups which both output and input
/// should be split into.
/// \param deformable_group The number of groups which deformable values and
/// output should be split into along the channel axis.
/// \param bilinear_interpolation_pad
/// The flag that determines the mode of bilinear
/// interpolation execution.
/// If the flag is `true` and the sampling location is
/// within one pixel outside of the feature map boundary,
/// then bilinear interpolation is performed on the zero
/// padded feature map. If the flag is `false` and the
/// sampling location is within one pixel outside of the
/// feature map boundary, then the sampling location
/// shifts to the inner boundary of the feature map.`
DeformableConvolution(const Output<Node>& arg,
const Output<Node>& offsets,
const Output<Node>& filters,
const Strides& strides,
const CoordinateDiff& pads_begin,
const CoordinateDiff& pads_end,
const Strides& dilations,
const PadType& auto_pad = PadType::EXPLICIT,
const int64_t group = 1,
const int64_t deformable_group = 1,
const bool bilinear_interpolation_pad = false);

/// \brief Constructs a conversion operation.
///
/// \param arg Node that produces the input tensor.
/// \param offsets Node producing the deformable values tensor.
/// \param filters Node producing the filters(kernels) tensor with OIZYX
/// layout.
/// \param mask Node producing the mask(mask) tensor.
/// \param strides Convolution strides.
/// \param pads_begin Amount of padding to be added to the beginning along
/// each axis. For example in case of a 2D input the value
/// of (1, 2) means that 1 element will be added to the
/// top and 2 elements to the left.
/// \param pads_end Amount of padding to be added to the end along each
/// axis.
/// \param dilations The distance in width and height between the weights
/// in the filters tensor.
/// \param auto_pad Specifies how the automatic calculation of padding
/// should be done.
/// \param group The number of groups which both output and input
/// should be split into.
/// \param deformable_group The number of groups which deformable values and
/// output should be split into along the channel axis.
/// \param bilinear_interpolation_pad
/// The flag that determines the mode of bilinear
/// interpolation execution.
/// If the flag is `true` and the sampling location is
/// within one pixel outside of the feature map boundary,
/// then bilinear interpolation is performed on the zero
/// padded feature map. If the flag is `false` and the
/// sampling location is within one pixel outside of the
/// feature map boundary, then the sampling location
/// shifts to the inner boundary of the feature map.
DeformableConvolution(const Output<Node>& arg,
const Output<Node>& offsets,
const Output<Node>& filters,
const Output<Node>& mask,
const Strides& strides,
const CoordinateDiff& pads_begin,
const CoordinateDiff& pads_end,
const Strides& dilations,
const PadType& auto_pad = PadType::EXPLICIT,
const int64_t group = 1,
const int64_t deformable_group = 1,
const bool bilinear_interpolation_pad = false);
bool visit_attributes(AttributeVisitor& visitor) override;

void validate_and_infer_types() override;

bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;

bool has_evaluate() const override;

std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;

bool get_bilinear_interpolation_pad() const {
return m_bilinear_interpolation_pad;
}

void set_bilinear_interpolation_pad(const bool bilinear_interpolation_pad) {
m_bilinear_interpolation_pad = bilinear_interpolation_pad;
}

private:
bool m_bilinear_interpolation_pad;
};
using ov::op::v8::DeformableConvolution;
} // namespace v8
} // namespace op
} // namespace ngraph
95 changes: 2 additions & 93 deletions ngraph/core/include/ngraph/op/deformable_psroi_pooling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,12 @@
#pragma once

#include "ngraph/op/op.hpp"
#include "openvino/op/deformable_psroi_pooling.hpp"

namespace ngraph {
namespace op {
namespace v1 {
class NGRAPH_API DeformablePSROIPooling : public Op {
public:
NGRAPH_RTTI_DECLARATION;

DeformablePSROIPooling() = default;
/// \brief Constructs a DeformablePSROIPooling operation
///
/// \param input Input tensor with position sensitive score maps
/// \param coords Input tensor with list of five element tuples
/// describing ROI coordinates
/// \param offsets Input tensor with transformation values
/// \param output_dim Pooled output channel number
/// \param group_size Number of horizontal bins per row to divide ROI area,
/// it defines output width and height
/// \param spatial_scale Multiplicative spatial scale factor to translate ROI
/// coordinates from their input scale to the scale used when
/// pooling
/// \param mode Specifies mode for pooling.
/// \param spatial_bins_x Specifies numbers of bins to divide ROI single
/// bin over width
/// \param spatial_bins_y Specifies numbers of bins to divide ROI single
/// bin over height
/// \param no_trans The flag that specifies whenever third input exists
/// and contains transformation (offset) values
/// \param trans_std The value that all transformation (offset) values are
/// multiplied with
/// \param part_size The number of parts the output tensor spatial dimensions
/// are divided into. Basically it is the height
/// and width of the third input
DeformablePSROIPooling(const Output<Node>& input,
const Output<Node>& coords,
const Output<Node>& offsets,
const int64_t output_dim,
const float spatial_scale,
const int64_t group_size = 1,
const std::string mode = "bilinear_deformable",
int64_t spatial_bins_x = 1,
int64_t spatial_bins_y = 1,
float trans_std = 1,
int64_t part_size = 1);

DeformablePSROIPooling(const Output<Node>& input,
const Output<Node>& coords,
const int64_t output_dim,
const float spatial_scale,
const int64_t group_size = 1,
const std::string mode = "bilinear_deformable",
int64_t spatial_bins_x = 1,
int64_t spatial_bins_y = 1,
float trans_std = 1,
int64_t part_size = 1);

bool visit_attributes(AttributeVisitor& visitor) override;

void validate_and_infer_types() override;

virtual std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;

int64_t get_output_dim() const {
return m_output_dim;
}
int64_t get_group_size() const {
return m_group_size;
}
float get_spatial_scale() const {
return m_spatial_scale;
}
const std::string& get_mode() const {
return m_mode;
}
int64_t get_spatial_bins_x() const {
return m_spatial_bins_x;
}
int64_t get_spatial_bins_y() const {
return m_spatial_bins_y;
}
float get_trans_std() const {
return m_trans_std;
}
int64_t get_part_size() const {
return m_part_size;
}

private:
int64_t m_output_dim;
float m_spatial_scale;
int64_t m_group_size = 1;
std::string m_mode = "bilinear_deformable";
int64_t m_spatial_bins_x = 1;
int64_t m_spatial_bins_y = 1;
float m_trans_std = 1.f;
int64_t m_part_size = 1;
};
using ov::op::v1::DeformablePSROIPooling;
} // namespace v1
} // namespace op
} // namespace ngraph
67 changes: 2 additions & 65 deletions ngraph/core/include/ngraph/op/depth_to_space.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,13 @@

#include "ngraph/op/op.hpp"
#include "ngraph/op/util/attr_types.hpp"
#include "openvino/op/depth_to_space.hpp"

namespace ngraph {
namespace op {
namespace v0 {
/// \brief DepthToSpace permutes data from the depth dimension of the input blob into
/// spatial dimensions.
///
/// \note Values from the depth dimension (assuming NCHW layout) are moved in
/// spatial blocks to the height and width dimensions.
///
/// Output node produces a tensor with shape:
/// [N, C/(blocksize * blocksize), H * blocksize, W * blocksize]
class NGRAPH_API DepthToSpace : public Op {
public:
NGRAPH_RTTI_DECLARATION;

enum class DepthToSpaceMode {
// The input depth is divided to [block_size, ..., block_size, new_depth]
BLOCKS_FIRST,
// The input depth is divided to [new_depth, block_size, ..., block_size]
DEPTH_FIRST
};

DepthToSpace() = default;
/// \brief Constructs a DepthToSpace operation.
///
/// \param data Node producing the input tensor
/// \param mode Specifies how the input depth dimension is split to block
/// coordinates
/// \param block_size The size of the block of values to be moved
DepthToSpace(const Output<Node>& data, const DepthToSpaceMode& mode, std::size_t block_size = 1);

DepthToSpace(const Output<Node>& data, const std::string& mode, std::size_t block_size = 1);
bool visit_attributes(AttributeVisitor& visitor) override;

std::size_t get_block_size() const {
return m_blocksize;
}
DepthToSpaceMode get_mode() const {
return m_mode;
}
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
void validate_and_infer_types() override;
bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;
bool has_evaluate() const override;

protected:
std::size_t m_blocksize;
DepthToSpaceMode m_mode;
};
using ov::op::v0::DepthToSpace;
} // namespace v0
using v0::DepthToSpace;
} // namespace op

NGRAPH_API
std::ostream& operator<<(std::ostream& s, const op::v0::DepthToSpace::DepthToSpaceMode& type);
} // namespace ngraph
namespace ov {

template <>
class NGRAPH_API AttributeAdapter<ngraph::op::v0::DepthToSpace::DepthToSpaceMode>
: public EnumAttributeAdapterBase<ngraph::op::v0::DepthToSpace::DepthToSpaceMode> {
public:
AttributeAdapter(ngraph::op::v0::DepthToSpace::DepthToSpaceMode& value)
: EnumAttributeAdapterBase<ngraph::op::v0::DepthToSpace::DepthToSpaceMode>(value) {}

static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<op::v0::DepthToSpace::DepthToSpaceMode>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
};

} // namespace ov
Loading

0 comments on commit 726e873

Please sign in to comment.