Deprecate nGraph API to don't include it to public API (#7171)

* Deprecate stopwatch

* Deprecate some utils

* Deprecate versions

* Moved slice_plan from the top level

* Fixed build

* Deprecate more old structures

* Fixed linux build
This commit is contained in:
Ilya Churaev 2021-09-01 08:17:11 +03:00 committed by GitHub
parent e6482037aa
commit 2b1637f28d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 147 additions and 84 deletions

View File

@ -21,8 +21,10 @@ enum class Type {
MAX,
};
NGRAPH_SUPPRESS_DEPRECATED_START
NGRAPH_API
std::ostream& operator<<(std::ostream& out, const Type& obj);
NGRAPH_SUPPRESS_DEPRECATED_END
} // namespace reduction
} // namespace ngraph

View File

@ -8,6 +8,7 @@
#include <stack>
#include <utility>
#include "ngraph/deprecated.hpp"
#include "ngraph/node.hpp"
#include "ngraph/shape.hpp"
#include "ngraph/type/element_type_traits.hpp"
@ -17,7 +18,8 @@ namespace ngraph {
///
///
template <typename V>
class Evaluator {
class NGRAPH_DEPRECATED("This class is deprecated and will be removed soon.") Evaluator {
NGRAPH_SUPPRESS_DEPRECATED_START
public:
/// \brief values we compute for outputs
using value_map = std::map<RawNodeOutput, V>;
@ -172,5 +174,6 @@ protected:
op_handler_map m_handlers;
op_handler m_default_handler;
value_map& m_value_map;
NGRAPH_SUPPRESS_DEPRECATED_END
};
} // namespace ngraph

View File

@ -6,11 +6,14 @@
#include "ngraph/attribute_adapter.hpp"
#include "ngraph/attribute_visitor.hpp"
#include "ngraph/deprecated.hpp"
#include "ngraph/factory.hpp"
namespace ngraph {
template <typename BASE_TYPE>
class FactoryAttributeAdapter : public VisitorAdapter {
class NGRAPH_DEPRECATED("This class is deprecated and will be removed soon.") FactoryAttributeAdapter
: public VisitorAdapter {
public:
FactoryAttributeAdapter(std::shared_ptr<BASE_TYPE>& ref) : m_ref(ref) {}

View File

@ -10,13 +10,19 @@
#include <string>
#include "ngraph/deprecated.hpp"
#ifdef IN_NGRAPH_LIBRARY
# error("ngraph.hpp is for external use only")
#endif
#include <ngraph/ngraph_visibility.hpp>
extern "C" NGRAPH_API const char* get_ngraph_version_string();
// clang-format off
extern "C" NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
const char* get_ngraph_version_string();
// clang-format on
namespace ngraph {
/// \brief Function to query parsed version information of the version of ngraph which
@ -30,6 +36,7 @@ namespace ngraph {
///
/// \note Throws a runtime_error if there is an error during parsing
NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
void get_version(size_t& major, size_t& minor, size_t& patch, std::string& extra);
} // namespace ngraph

View File

@ -0,0 +1,56 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <set>
#include "ngraph/axis_set.hpp"
#include "ngraph/shape.hpp"
namespace ngraph {
//
// In various places, like ConstantFolding, it is
// useful to transform DynSlice by converting it to a sequence of ops:
//
// Slice (to do the basic slicing)
// |
// v
// Reshape (non-transposing, to handle shrinks)
// |
// v
// Reverse (to emulate backwards stride)
//
// (The Reshape, Reverse, or both may be omitted if they would just be
// identities.)
//
// A SlicePlan is used to collect parameters for these ops.
//
struct NGRAPH_API SlicePlan {
// Parameters for the Slice
std::vector<int64_t> begins;
std::vector<int64_t> ends;
std::vector<int64_t> strides;
// Shapes coming into, and going out of, the Reshape.
Shape reshape_in_shape;
Shape reshape_out_shape;
// Parameters for the Reverse
AxisSet reverse_axes;
bool operator==(const SlicePlan& other) const;
bool operator!=(const SlicePlan& other) const;
};
SlicePlan NGRAPH_API make_slice_plan(const Shape& input_shape,
const std::vector<int64_t>& begins,
const std::vector<int64_t>& ends,
const std::vector<int64_t>& strides,
const AxisSet& lower_bounds_mask,
const AxisSet& upper_bounds_mask,
const AxisSet& new_axis_mask,
const AxisSet& shrink_axis_mask,
const AxisSet& ellipsis_mask);
} // namespace ngraph

View File

@ -6,51 +6,4 @@
#include <set>
#include "ngraph/axis_set.hpp"
#include "ngraph/shape.hpp"
namespace ngraph {
//
// In various places, like ConstantFolding, it is
// useful to transform DynSlice by converting it to a sequence of ops:
//
// Slice (to do the basic slicing)
// |
// v
// Reshape (non-transposing, to handle shrinks)
// |
// v
// Reverse (to emulate backwards stride)
//
// (The Reshape, Reverse, or both may be omitted if they would just be
// identities.)
//
// A SlicePlan is used to collect parameters for these ops.
//
struct NGRAPH_API SlicePlan {
// Parameters for the Slice
std::vector<int64_t> begins;
std::vector<int64_t> ends;
std::vector<int64_t> strides;
// Shapes coming into, and going out of, the Reshape.
Shape reshape_in_shape;
Shape reshape_out_shape;
// Parameters for the Reverse
AxisSet reverse_axes;
bool operator==(const SlicePlan& other) const;
bool operator!=(const SlicePlan& other) const;
};
SlicePlan NGRAPH_API make_slice_plan(const Shape& input_shape,
const std::vector<int64_t>& begins,
const std::vector<int64_t>& ends,
const std::vector<int64_t>& strides,
const AxisSet& lower_bounds_mask,
const AxisSet& upper_bounds_mask,
const AxisSet& new_axis_mask,
const AxisSet& shrink_axis_mask,
const AxisSet& ellipsis_mask);
} // namespace ngraph
#include "ngraph/op/util/slice_plan.hpp"

View File

@ -34,8 +34,6 @@ using ov::Node;
class stopwatch;
namespace runtime {
class Backend;
class Value;
class Tensor;
} // namespace runtime
@ -60,8 +58,10 @@ std::string vector_to_string(const T& v) {
}
NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
size_t hash_combine(const std::vector<size_t>& list);
NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
void dump(std::ostream& out, const void*, size_t);
NGRAPH_API
std::string to_lower(const std::string& s);
@ -73,6 +73,7 @@ NGRAPH_API
std::vector<std::string> split(const std::string& s, char delimiter, bool trim = false);
template <typename T>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
std::string locale_string(T x) {
std::stringstream ss;
ss.imbue(std::locale(""));
@ -80,7 +81,7 @@ std::string locale_string(T x) {
return ss.str();
}
class NGRAPH_API stopwatch {
class NGRAPH_API NGRAPH_DEPRECATED("It is obsolete structure and will be removed soon") stopwatch {
public:
void start() {
if (m_active == false) {
@ -122,6 +123,7 @@ private:
/// Parses a string containing a literal of the underlying type.
template <typename T>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
T parse_string(const std::string& s) {
T result;
std::stringstream ss;
@ -140,26 +142,33 @@ T parse_string(const std::string& s) {
/// template specializations for float and double to handle INFINITY, -INFINITY
/// and NaN values.
template <>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
NGRAPH_API float parse_string<float>(const std::string& s);
template <>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
NGRAPH_API double parse_string<double>(const std::string& s);
/// template specializations for int8_t and uint8_t to handle the fact that default
/// implementation ends up treating values as characters so that the number "0" turns into
/// the parsed value 48, which is it's ASCII value
template <>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
NGRAPH_API int8_t parse_string<int8_t>(const std::string& s);
template <>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
NGRAPH_API uint8_t parse_string<uint8_t>(const std::string& s);
/// Parses a list of strings containing literals of the underlying type.
template <typename T>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
std::vector<T> parse_string(const std::vector<std::string>& ss) {
NGRAPH_SUPPRESS_DEPRECATED_START
std::vector<T> result(ss.size());
std::transform(ss.begin(), ss.end(), result.begin(), [](const std::string& s) {
return parse_string<T>(s);
});
return result;
NGRAPH_SUPPRESS_DEPRECATED_END
}
template <typename T>
@ -168,30 +177,41 @@ T ceil_div(const T& x, const T& y) {
}
template <typename T>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
T subtract_or_zero(T x, T y) {
return y > x ? 0 : x - y;
}
NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
void* ngraph_malloc(size_t size);
NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
void ngraph_free(void*);
NGRAPH_API
size_t round_up(size_t size, size_t alignment);
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
bool is_valid_permutation(ngraph::AxisVector permutation, ngraph::Rank rank = Rank::dynamic());
template <typename T>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
T apply_permutation(T input, ngraph::AxisVector order);
extern template NGRAPH_API AxisVector apply_permutation<AxisVector>(AxisVector input, AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
AxisVector apply_permutation<AxisVector>(AxisVector input, AxisVector order);
extern template NGRAPH_API Coordinate apply_permutation<Coordinate>(Coordinate input, AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
Coordinate apply_permutation<Coordinate>(Coordinate input, AxisVector order);
extern template NGRAPH_API Strides apply_permutation<Strides>(Strides input, AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon") Strides
apply_permutation<Strides>(Strides input, AxisVector order);
extern template NGRAPH_API Shape apply_permutation<Shape>(Shape input, AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon") Shape
apply_permutation<Shape>(Shape input, AxisVector order);
template <>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
NGRAPH_API PartialShape apply_permutation(PartialShape input, AxisVector order);
NGRAPH_API
@ -317,6 +337,7 @@ private:
///
/// \note Throws a runtime_error if there is an error during parsing
NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
void parse_version_string(std::string version, size_t& major, size_t& minor, size_t& patch, std::string& extra);
template <typename T>

View File

@ -123,8 +123,10 @@ CoordinateTransform::CoordinateTransform(const Shape& source_shape,
std::vector<std::ptrdiff_t> padded_upper_bounds;
for (size_t i = 0; i < m_n_axes; i++) {
NGRAPH_SUPPRESS_DEPRECATED_START
std::ptrdiff_t padded_upper_bound = subtract_or_zero(source_shape[i], size_t(1)) * target_dilation_strides[i] +
1 + target_padding_below[i] + target_padding_above[i];
NGRAPH_SUPPRESS_DEPRECATED_END
if (padded_upper_bound < 0) {
std::stringstream ss;

View File

@ -7,6 +7,9 @@
#include "ngraph/log.hpp"
#include "ngraph/type.hpp"
NGRAPH_SUPPRESS_DEPRECATED_START
using namespace ngraph;
namespace ov {
template <>
EnumNames<ngraph::reduction::Type>& EnumNames<ngraph::reduction::Type>::get() {

View File

@ -15,7 +15,9 @@ extern "C" NGRAPH_API const char* get_ngraph_version_string() {
namespace ngraph {
NGRAPH_API void get_version(size_t& major, size_t& minor, size_t& patch, std::string& extra) {
NGRAPH_SUPPRESS_DEPRECATED_START
string version = NGRAPH_VERSION_NUMBER;
ngraph::parse_version_string(version, major, minor, patch, extra);
NGRAPH_SUPPRESS_DEPRECATED_END
}
} // namespace ngraph

View File

@ -56,6 +56,7 @@ op::Constant::Constant(const shared_ptr<runtime::Tensor>& tensor) {
op::Constant::Constant(const element::Type& type, const Shape& shape, const std::vector<std::string>& values)
: Constant(type, shape) {
NGRAPH_SUPPRESS_DEPRECATED_START
NODE_VALIDATION_CHECK(this,
values.size() == shape_size(m_shape) || values.size() == 1,
"Did not get the expected number of literals for a constant of shape ",
@ -182,6 +183,7 @@ op::Constant::Constant(const element::Type& type, const Shape& shape, const std:
}
m_all_elements_bitwise_identical = are_all_data_elements_bitwise_identical();
}
NGRAPH_SUPPRESS_DEPRECATED_END
}
op::Constant::Constant(const element::Type& type, const Shape& shape) : m_element_type(type), m_shape(shape) {

View File

@ -42,6 +42,7 @@ void op::v1::Transpose::validate_and_infer_types() {
set_input_is_relevant_to_shape(1);
NGRAPH_SUPPRESS_DEPRECATED_START
if (const auto& input_const = get_constant_from_source(input_value(1))) {
auto permutation = input_const->get_axis_vector_val();
if (permutation.empty()) {
@ -58,6 +59,7 @@ void op::v1::Transpose::validate_and_infer_types() {
} else {
set_output_type(0, get_input_element_type(0), PartialShape::dynamic(arg_shape.rank()));
}
NGRAPH_SUPPRESS_DEPRECATED_END
}
shared_ptr<Node> op::v1::Transpose::clone_with_new_inputs(const OutputVector& new_args) const {

View File

@ -46,6 +46,7 @@ pass::Manager::~Manager() {}
pass::Manager::Manager(std::shared_ptr<ngraph::pass::PassConfig> pass_config) : m_pass_config(std::move(pass_config)) {}
void pass::Manager::run_passes(shared_ptr<Function> func) {
NGRAPH_SUPPRESS_DEPRECATED_START
OV_ITT_SCOPED_TASK(ov::itt::domains::nGraph, "pass::Manager::run_passes");
static bool profile_enabled = getenv_bool("NGRAPH_PROFILE_PASS_ENABLE");
@ -67,7 +68,6 @@ void pass::Manager::run_passes(shared_ptr<Function> func) {
pass_timer.start();
NGRAPH_SUPPRESS_DEPRECATED_START
if (auto matcher_pass = dynamic_pointer_cast<MatcherPass>(pass)) {
// This checks is to skip the graph transformation when the graph pass relies on
// static shape but the function state is dynamic.
@ -106,7 +106,6 @@ void pass::Manager::run_passes(shared_ptr<Function> func) {
function_changed |= node_pass->run_on_node(n);
}
}
NGRAPH_SUPPRESS_DEPRECATED_END
if (m_visualize) {
// visualizations and serializations will be named after the outermost function
@ -131,4 +130,5 @@ void pass::Manager::run_passes(shared_ptr<Function> func) {
if (profile_enabled) {
cout << "passes done in " << overall_timer.get_milliseconds() << "ms\n";
}
NGRAPH_SUPPRESS_DEPRECATED_END
}

View File

@ -15,6 +15,7 @@ using namespace std;
runtime::AlignedBuffer::AlignedBuffer() : m_allocated_buffer(nullptr), m_aligned_buffer(nullptr), m_byte_size(0) {}
runtime::AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment) : m_byte_size(byte_size) {
NGRAPH_SUPPRESS_DEPRECATED_START
m_byte_size = std::max<size_t>(1, byte_size);
size_t allocation_size = m_byte_size + alignment;
m_allocated_buffer = static_cast<char*>(ngraph_malloc(allocation_size));
@ -24,6 +25,7 @@ runtime::AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment) : m_by
if (mod != 0) {
m_aligned_buffer += (alignment - mod);
}
NGRAPH_SUPPRESS_DEPRECATED_END
}
runtime::AlignedBuffer::AlignedBuffer(AlignedBuffer&& other)

View File

@ -42,6 +42,7 @@ runtime::HostTensor::HostTensor(const Output<Node>& value)
NGRAPH_SUPPRESS_DEPRECATED_END
void runtime::HostTensor::allocate_buffer() {
NGRAPH_SUPPRESS_DEPRECATED_START
NGRAPH_CHECK(get_partial_shape().is_static(),
"Attempt to allocate buffer for tensor with partial shape: ",
get_partial_shape());
@ -63,6 +64,7 @@ void runtime::HostTensor::allocate_buffer() {
m_aligned_buffer_pool = (allocated_buffer_pool + alignment - mod);
}
}
NGRAPH_SUPPRESS_DEPRECATED_END
}
NGRAPH_SUPPRESS_DEPRECATED_START
@ -78,9 +80,11 @@ void runtime::HostTensor::initialize(const std::shared_ptr<op::v0::Constant>& co
}
runtime::HostTensor::~HostTensor() {
NGRAPH_SUPPRESS_DEPRECATED_START
if (m_allocated_buffer_pool != nullptr) {
ngraph_free(m_allocated_buffer_pool);
}
NGRAPH_SUPPRESS_DEPRECATED_END
}
void* runtime::HostTensor::get_data_ptr() {

View File

@ -8,9 +8,11 @@
namespace std {
size_t std::hash<ngraph::DiscreteTypeInfo>::operator()(const ngraph::DiscreteTypeInfo& k) const {
NGRAPH_SUPPRESS_DEPRECATED_START
size_t name_hash = hash<string>()(string(k.name));
size_t version_hash = hash<decltype(k.version)>()(k.version);
// don't use parent for hash calculation, it is not a part of type (yet)
return ngraph::hash_combine(vector<size_t>{name_hash, version_hash});
NGRAPH_SUPPRESS_DEPRECATED_END
}
} // namespace std

View File

@ -22,6 +22,7 @@
#include "ngraph/partial_shape.hpp"
#include "ngraph/shape.hpp"
NGRAPH_SUPPRESS_DEPRECATED_START
using namespace std;
using namespace ngraph;

View File

@ -23,6 +23,7 @@
#include "ngraph/type/element_type_traits.hpp"
#include "ngraph/util.hpp"
NGRAPH_SUPPRESS_DEPRECATED_START
using namespace std;
using namespace ngraph;

View File

@ -139,6 +139,7 @@ TEST(bfloat16, numeric_limits) {
}
TEST(benchmark, bfloat16) {
NGRAPH_SUPPRESS_DEPRECATED_START
size_t buffer_size = 128 * 3 * 224 * 224;
ngraph::runtime::AlignedBuffer data(buffer_size * sizeof(float), 4096);
float* f = static_cast<float*>(data.get_ptr());
@ -197,6 +198,7 @@ TEST(benchmark, bfloat16) {
timer.stop();
NGRAPH_INFO << "float to bfloat16 round to nearest even " << timer.get_milliseconds() << "ms";
}
NGRAPH_SUPPRESS_DEPRECATED_END
}
TEST(bfloat16, assigns) {

View File

@ -7,11 +7,11 @@
#include <initializer_list>
#include <iostream>
#include <memory>
#include <ngraph/runtime/host_tensor.hpp>
#include <sstream>
#include <string>
#include <vector>
#include <ngraph/runtime/host_tensor.hpp>
#include "backend.hpp"
#include "int_backend_visibility.hpp"
#include "ngraph/ops.hpp"
@ -22,25 +22,20 @@
#include "ngraph/runtime/reference/tensor_iterator.hpp"
#include "ngraph/runtime/tensor.hpp"
namespace ngraph
{
namespace runtime
{
namespace interpreter
{
class INTBackend;
class INTExecutable;
} // namespace interpreter
} // namespace runtime
} // namespace ngraph
namespace ngraph {
namespace runtime {
namespace interpreter {
class INTBackend;
class INTExecutable;
} // namespace interpreter
} // namespace runtime
} // namespace ngraph
class INTERPRETER_BACKEND_API ngraph::runtime::interpreter::INTExecutable : public Executable
{
class INTERPRETER_BACKEND_API ngraph::runtime::interpreter::INTExecutable : public Executable {
friend class INTBackend;
public:
INTExecutable(const std::shared_ptr<Function>& function,
bool enable_performance_collection = false);
INTExecutable(const std::shared_ptr<Function>& function, bool enable_performance_collection = false);
bool call(const std::vector<std::shared_ptr<Tensor>>& outputs,
const std::vector<std::shared_ptr<Tensor>>& inputs) override;
@ -53,11 +48,11 @@ public:
std::shared_ptr<runtime::Tensor> create_output_tensor(size_t output_index) override;
std::vector<std::shared_ptr<runtime::Tensor>>
create_input_tensor(size_t input_index, size_t pipeline_depth) override;
std::vector<std::shared_ptr<runtime::Tensor>> create_input_tensor(size_t input_index,
size_t pipeline_depth) override;
std::vector<std::shared_ptr<runtime::Tensor>>
create_output_tensor(size_t output_index, size_t pipeline_depth) override;
std::vector<std::shared_ptr<runtime::Tensor>> create_output_tensor(size_t output_index,
size_t pipeline_depth) override;
protected:
std::shared_ptr<ngraph::op::Parameter> get_parameter(size_t index) const;
@ -69,13 +64,13 @@ protected:
bool m_nan_check_enabled = false;
bool m_performance_counters_enabled = false;
std::shared_ptr<Function> m_function;
NGRAPH_SUPPRESS_DEPRECATED_START
std::unordered_map<std::shared_ptr<const Node>, stopwatch> m_timer_map;
NGRAPH_SUPPRESS_DEPRECATED_END
std::vector<std::shared_ptr<Node>> m_nodes;
static void perform_nan_check(const std::vector<std::shared_ptr<HostTensor>>&,
const Node* op = nullptr);
struct InfoForNMS5
{
static void perform_nan_check(const std::vector<std::shared_ptr<HostTensor>>&, const Node* op = nullptr);
struct InfoForNMS5 {
int64_t max_output_boxes_per_class;
float iou_threshold;
float score_threshold;