Skip to content

Commit

Permalink
Moved AxisSet, AxisVector, Coordinate, CoordinateDiff to ov (#7237)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyachur authored Aug 26, 2021
1 parent 4a468ac commit 0bc991d
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 220 deletions.
49 changes: 2 additions & 47 deletions ngraph/core/include/ngraph/axis_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,8 @@

#include "ngraph/attribute_adapter.hpp"
#include "ngraph/ngraph_visibility.hpp"
#include "openvino/core/axis_set.hpp"

namespace ngraph {
/// \brief A set of axes.
class AxisSet : public std::set<size_t> {
public:
NGRAPH_API AxisSet();

NGRAPH_API AxisSet(const std::initializer_list<size_t>& axes);

NGRAPH_API AxisSet(const std::set<size_t>& axes);

NGRAPH_API AxisSet(const std::vector<size_t>& axes);

NGRAPH_API AxisSet(const AxisSet& axes);

NGRAPH_API AxisSet& operator=(const AxisSet& v);

NGRAPH_API AxisSet& operator=(AxisSet&& v) noexcept;

NGRAPH_API std::vector<int64_t> to_vector() const;
};

NGRAPH_API
std::ostream& operator<<(std::ostream& s, const AxisSet& axis_set);
using ov::AxisSet;
} // namespace ngraph

namespace ov {

template <>
class NGRAPH_API AttributeAdapter<ngraph::AxisSet> : public ValueAccessor<std::vector<int64_t>> {
public:
AttributeAdapter(ngraph::AxisSet& value) : m_ref(value) {}

const std::vector<int64_t>& get() override;
void set(const std::vector<int64_t>& value) override;
static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<AxisSet>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
operator ngraph::AxisSet&() {
return m_ref;
}

protected:
ngraph::AxisSet& m_ref;
std::vector<int64_t> m_buffer;
bool m_buffer_valid{false};
};

} // namespace ov
43 changes: 2 additions & 41 deletions ngraph/core/include/ngraph/axis_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,9 @@

#include "ngraph/attribute_adapter.hpp"
#include "ngraph/ngraph_visibility.hpp"
#include "openvino/core/axis_vector.hpp"

namespace ngraph {
/// \brief A vector of axes.
class AxisVector : public std::vector<size_t> {
public:
NGRAPH_API AxisVector(const std::initializer_list<size_t>& axes);

NGRAPH_API AxisVector(const std::vector<size_t>& axes);

NGRAPH_API AxisVector(const AxisVector& axes);

NGRAPH_API explicit AxisVector(size_t n);

template <class InputIterator>
AxisVector(InputIterator first, InputIterator last) : std::vector<size_t>(first, last) {}

NGRAPH_API AxisVector();

NGRAPH_API ~AxisVector();

NGRAPH_API AxisVector& operator=(const AxisVector& v);

NGRAPH_API AxisVector& operator=(AxisVector&& v) noexcept;
};

NGRAPH_API
std::ostream& operator<<(std::ostream& s, const AxisVector& axis_vector);
using ov::AxisVector;
} // namespace ngraph

namespace ov {

template <>
class NGRAPH_API AttributeAdapter<ngraph::AxisVector>
: public IndirectVectorValueAccessor<ngraph::AxisVector, std::vector<int64_t>> {
public:
AttributeAdapter(ngraph::AxisVector& value)
: IndirectVectorValueAccessor<ngraph::AxisVector, std::vector<int64_t>>(value) {}

static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<AxisVector>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
};

} // namespace ov
42 changes: 2 additions & 40 deletions ngraph/core/include/ngraph/coordinate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,9 @@
#include "ngraph/attribute_adapter.hpp"
#include "ngraph/axis_set.hpp"
#include "ngraph/shape.hpp"
#include "openvino/core/coordinate.hpp"

namespace ngraph {
/// \brief Coordinates for a tensor element
class Coordinate : public std::vector<size_t> {
public:
NGRAPH_API Coordinate();
NGRAPH_API Coordinate(const std::initializer_list<size_t>& axes);

NGRAPH_API Coordinate(const Shape& shape);

NGRAPH_API Coordinate(const std::vector<size_t>& axes);

NGRAPH_API Coordinate(const Coordinate& axes);

NGRAPH_API Coordinate(size_t n, size_t initial_value = 0);

NGRAPH_API ~Coordinate();

template <class InputIterator>
Coordinate(InputIterator first, InputIterator last) : std::vector<size_t>(first, last) {}

NGRAPH_API Coordinate& operator=(const Coordinate& v);

NGRAPH_API Coordinate& operator=(Coordinate&& v) noexcept;
};

NGRAPH_API
std::ostream& operator<<(std::ostream& s, const Coordinate& coordinate);
using ov::Coordinate;
} // namespace ngraph

namespace ov {
template <>
class NGRAPH_API AttributeAdapter<ngraph::Coordinate>
: public IndirectVectorValueAccessor<ngraph::Coordinate, std::vector<int64_t>> {
public:
AttributeAdapter(ngraph::Coordinate& value)
: IndirectVectorValueAccessor<ngraph::Coordinate, std::vector<int64_t>>(value) {}

static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<Coordinate>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
};
} // namespace ov
45 changes: 2 additions & 43 deletions ngraph/core/include/ngraph/coordinate_diff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,9 @@

#include "ngraph/attribute_adapter.hpp"
#include "ngraph/ngraph_visibility.hpp"
#include "openvino/core/coordinate_diff.hpp"

namespace ngraph {
/// \brief A difference (signed) of tensor element coordinates.
class CoordinateDiff : public std::vector<std::ptrdiff_t> {
public:
NGRAPH_API CoordinateDiff(const std::initializer_list<std::ptrdiff_t>& diffs);

NGRAPH_API CoordinateDiff(const std::vector<std::ptrdiff_t>& diffs);

NGRAPH_API CoordinateDiff(const CoordinateDiff& diffs);

NGRAPH_API explicit CoordinateDiff(size_t n, std::ptrdiff_t initial_value = 0);

template <class InputIterator>
CoordinateDiff(InputIterator first, InputIterator last) : std::vector<std::ptrdiff_t>(first, last) {}

NGRAPH_API ~CoordinateDiff();

NGRAPH_API CoordinateDiff();

NGRAPH_API CoordinateDiff& operator=(const CoordinateDiff& v);

NGRAPH_API CoordinateDiff& operator=(CoordinateDiff&& v) noexcept;
};

NGRAPH_API
std::ostream& operator<<(std::ostream& s, const CoordinateDiff& coordinate_diff);
using ov::CoordinateDiff;
} // namespace ngraph

namespace ov {

template <>
class NGRAPH_API AttributeAdapter<ngraph::CoordinateDiff>
: public IndirectVectorValueAccessor<ngraph::CoordinateDiff, std::vector<int64_t>>

{
public:
AttributeAdapter(ngraph::CoordinateDiff& value)
: IndirectVectorValueAccessor<ngraph::CoordinateDiff, std::vector<int64_t>>(value) {}

static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<CoordinateDiff>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
};

} // namespace ov
60 changes: 60 additions & 0 deletions ngraph/core/include/openvino/core/axis_set.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <cstddef>
#include <ostream>
#include <set>
#include <vector>

#include "openvino/core/attribute_adapter.hpp"
#include "openvino/core/core_visibility.hpp"

namespace ov {
/// \brief A set of axes.
class AxisSet : public std::set<size_t> {
public:
OPENVINO_API AxisSet();

OPENVINO_API AxisSet(const std::initializer_list<size_t>& axes);

OPENVINO_API AxisSet(const std::set<size_t>& axes);

OPENVINO_API AxisSet(const std::vector<size_t>& axes);

OPENVINO_API AxisSet(const AxisSet& axes);

OPENVINO_API AxisSet& operator=(const AxisSet& v);

OPENVINO_API AxisSet& operator=(AxisSet&& v) noexcept;

OPENVINO_API std::vector<int64_t> to_vector() const;
};

OPENVINO_API
std::ostream& operator<<(std::ostream& s, const AxisSet& axis_set);

template <>
class OPENVINO_API AttributeAdapter<ov::AxisSet> : public ValueAccessor<std::vector<int64_t>> {
public:
AttributeAdapter(ov::AxisSet& value) : m_ref(value) {}

const std::vector<int64_t>& get() override;
void set(const std::vector<int64_t>& value) override;
static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<AxisSet>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
operator ov::AxisSet&() {
return m_ref;
}

protected:
ov::AxisSet& m_ref;
std::vector<int64_t> m_buffer;
bool m_buffer_valid{false};
};

} // namespace ov
52 changes: 52 additions & 0 deletions ngraph/core/include/openvino/core/axis_vector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <cstddef>
#include <ostream>
#include <vector>

#include "openvino/core/attribute_adapter.hpp"
#include "openvino/core/core_visibility.hpp"

namespace ov {
/// \brief A vector of axes.
class AxisVector : public std::vector<size_t> {
public:
OPENVINO_API AxisVector(const std::initializer_list<size_t>& axes);

OPENVINO_API AxisVector(const std::vector<size_t>& axes);

OPENVINO_API AxisVector(const AxisVector& axes);

OPENVINO_API explicit AxisVector(size_t n);

template <class InputIterator>
AxisVector(InputIterator first, InputIterator last) : std::vector<size_t>(first, last) {}

OPENVINO_API AxisVector();

OPENVINO_API ~AxisVector();

OPENVINO_API AxisVector& operator=(const AxisVector& v);

OPENVINO_API AxisVector& operator=(AxisVector&& v) noexcept;
};

OPENVINO_API
std::ostream& operator<<(std::ostream& s, const AxisVector& axis_vector);

template <>
class OPENVINO_API AttributeAdapter<AxisVector> : public IndirectVectorValueAccessor<AxisVector, std::vector<int64_t>> {
public:
AttributeAdapter(AxisVector& value) : IndirectVectorValueAccessor<AxisVector, std::vector<int64_t>>(value) {}

static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<AxisVector>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
};

} // namespace ov
51 changes: 51 additions & 0 deletions ngraph/core/include/openvino/core/coordinate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <algorithm>
#include <vector>

#include "ngraph/shape.hpp"
#include "openvino/core/core_visibility.hpp"

namespace ov {
/// \brief Coordinates for a tensor element
class Coordinate : public std::vector<size_t> {
public:
OPENVINO_API Coordinate();
OPENVINO_API Coordinate(const std::initializer_list<size_t>& axes);

OPENVINO_API Coordinate(const ngraph::Shape& shape);

OPENVINO_API Coordinate(const std::vector<size_t>& axes);

OPENVINO_API Coordinate(const Coordinate& axes);

OPENVINO_API Coordinate(size_t n, size_t initial_value = 0);

OPENVINO_API ~Coordinate();

template <class InputIterator>
Coordinate(InputIterator first, InputIterator last) : std::vector<size_t>(first, last) {}

OPENVINO_API Coordinate& operator=(const Coordinate& v);

OPENVINO_API Coordinate& operator=(Coordinate&& v) noexcept;
};

OPENVINO_API
std::ostream& operator<<(std::ostream& s, const Coordinate& coordinate);

template <>
class OPENVINO_API AttributeAdapter<Coordinate> : public IndirectVectorValueAccessor<Coordinate, std::vector<int64_t>> {
public:
AttributeAdapter(Coordinate& value) : IndirectVectorValueAccessor<Coordinate, std::vector<int64_t>>(value) {}

static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<Coordinate>", 0};
const DiscreteTypeInfo& get_type_info() const override {
return type_info;
}
};
} // namespace ov
Loading

0 comments on commit 0bc991d

Please sign in to comment.