Moved ie::Parameter to new API (#7584)
* Fixed typo * Moved ie::Parameter to new API * Fixed compilation for Android
This commit is contained in:
parent
67f2b68e38
commit
377f46898c
@ -20,341 +20,21 @@
|
||||
#include <vector>
|
||||
|
||||
#include "ie_blob.h"
|
||||
#include "openvino/runtime/parameter.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
|
||||
/**
|
||||
* @brief This class represents an object to work with different parameters
|
||||
*
|
||||
*/
|
||||
class INFERENCE_ENGINE_API_CLASS(Parameter) {
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*/
|
||||
Parameter() = default;
|
||||
using ov::runtime::Parameter;
|
||||
using ov::runtime::ParamMap;
|
||||
|
||||
/**
|
||||
* @brief Move constructor
|
||||
*
|
||||
* @param parameter Parameter object
|
||||
*/
|
||||
Parameter(Parameter&& parameter) noexcept {
|
||||
std::swap(ptr, parameter.ptr);
|
||||
}
|
||||
} // namespace InferenceEngine
|
||||
|
||||
/**
|
||||
* @brief Copy constructor
|
||||
*
|
||||
* @param parameter Parameter object
|
||||
*/
|
||||
Parameter(const Parameter& parameter) {
|
||||
*this = parameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructor creates parameter with object
|
||||
*
|
||||
* @tparam T Parameter type
|
||||
* @tparam U Identity type-transformation
|
||||
* @param parameter object
|
||||
*/
|
||||
template <class T,
|
||||
typename = typename std::enable_if<!std::is_same<typename std::decay<T>::type, Parameter>::value &&
|
||||
!std::is_abstract<typename std::decay<T>::type>::value>::type>
|
||||
Parameter(T&& parameter) {
|
||||
static_assert(!std::is_same<typename std::decay<T>::type, Parameter>::value, "To prevent recursion");
|
||||
ptr = new RealData<typename std::decay<T>::type>(std::forward<T>(parameter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructor creates string parameter from char *
|
||||
*
|
||||
* @param str char array
|
||||
*/
|
||||
Parameter(const char* str) : Parameter(std::string(str)) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~Parameter();
|
||||
|
||||
/**
|
||||
* Copy operator for Parameter
|
||||
* @param parameter Parameter object
|
||||
* @return Parameter
|
||||
*/
|
||||
Parameter& operator=(const Parameter& parameter) {
|
||||
if (this == ¶meter) {
|
||||
return *this;
|
||||
}
|
||||
clear();
|
||||
if (!parameter.empty())
|
||||
ptr = parameter.ptr->copy();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a value from parameter
|
||||
*/
|
||||
void clear() {
|
||||
delete ptr;
|
||||
ptr = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that parameter contains a value
|
||||
* @return false if parameter contains a value else false
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
return nullptr == ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the type of value
|
||||
* @tparam T Type of value
|
||||
* @return true if type of value is correct
|
||||
*/
|
||||
template <class T>
|
||||
bool is() const {
|
||||
return empty() ? false : ptr->is(typeid(T));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <typename T>
|
||||
T&& as() && {
|
||||
return std::move(dyn_cast<T>(ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
T& as() & {
|
||||
return dyn_cast<T>(ptr);
|
||||
}
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
const T& as() const& {
|
||||
return dyn_cast<T>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator T &&() && {
|
||||
return std::move(dyn_cast<typename std::remove_cv<T>::type>(ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator T&() & {
|
||||
return dyn_cast<typename std::remove_cv<T>::type>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator const T&() const& {
|
||||
return dyn_cast<typename std::remove_cv<T>::type>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator T&() const& {
|
||||
return dyn_cast<typename std::remove_cv<T>::type>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The comparison operator for the Parameter
|
||||
*
|
||||
* @param rhs object to compare
|
||||
* @return true if objects are equal
|
||||
*/
|
||||
bool operator==(const Parameter& rhs) const {
|
||||
return *ptr == *(rhs.ptr);
|
||||
}
|
||||
/**
|
||||
* @brief The comparison operator for the Parameter
|
||||
*
|
||||
* @param rhs object to compare
|
||||
* @return true if objects aren't equal
|
||||
*/
|
||||
bool operator!=(const Parameter& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prints underlying object to the given output stream.
|
||||
* Uses operator<< if it is defined, leaves stream unchanged otherwise.
|
||||
* In case of empty parameter or nullptr stream immediately returns.
|
||||
*
|
||||
* @param object Object to be printed to the given output stream.
|
||||
* @param stream Output stream object will be printed to.
|
||||
*/
|
||||
friend void PrintTo(const Parameter& object, std::ostream* stream) {
|
||||
if (object.empty() || !stream) {
|
||||
return;
|
||||
}
|
||||
object.ptr->print(*stream);
|
||||
}
|
||||
|
||||
private:
|
||||
template <class T, class EqualTo>
|
||||
struct CheckOperatorEqual {
|
||||
template <class U, class V>
|
||||
static auto test(U*) -> decltype(std::declval<U>() == std::declval<V>()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename, typename>
|
||||
static auto test(...) -> std::false_type {
|
||||
return {};
|
||||
}
|
||||
|
||||
using type = typename std::is_same<bool, decltype(test<T, EqualTo>(nullptr))>::type;
|
||||
};
|
||||
|
||||
template <class T, class EqualTo = T>
|
||||
struct HasOperatorEqual : CheckOperatorEqual<T, EqualTo>::type {};
|
||||
|
||||
template <class T, class U>
|
||||
struct CheckOutputStreamOperator {
|
||||
template <class V, class W>
|
||||
static auto test(W*) -> decltype(std::declval<V&>() << std::declval<W>(), std::true_type()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename, typename>
|
||||
static auto test(...) -> std::false_type {
|
||||
return {};
|
||||
}
|
||||
|
||||
using type = typename std::is_same<std::true_type, decltype(test<T, U>(nullptr))>::type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct HasOutputStreamOperator : CheckOutputStreamOperator<std::ostream, T>::type {};
|
||||
|
||||
struct Any {
|
||||
#ifdef __ANDROID__
|
||||
virtual ~Any();
|
||||
#else
|
||||
virtual ~Any() = default;
|
||||
#endif
|
||||
virtual bool is(const std::type_info&) const = 0;
|
||||
virtual Any* copy() const = 0;
|
||||
virtual bool operator==(const Any& rhs) const = 0;
|
||||
virtual void print(std::ostream&) const = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct RealData : Any, std::tuple<T> {
|
||||
using std::tuple<T>::tuple;
|
||||
|
||||
bool is(const std::type_info& id) const override {
|
||||
return id == typeid(T);
|
||||
}
|
||||
Any* copy() const override {
|
||||
return new RealData{get()};
|
||||
}
|
||||
|
||||
T& get() & {
|
||||
return std::get<0>(*static_cast<std::tuple<T>*>(this));
|
||||
}
|
||||
|
||||
const T& get() const& {
|
||||
return std::get<0>(*static_cast<const std::tuple<T>*>(this));
|
||||
}
|
||||
|
||||
template <class U>
|
||||
typename std::enable_if<!HasOperatorEqual<U>::value, bool>::type equal(const Any& left, const Any& rhs) const {
|
||||
IE_THROW() << "Parameter doesn't contain equal operator";
|
||||
}
|
||||
|
||||
template <class U>
|
||||
typename std::enable_if<HasOperatorEqual<U>::value, bool>::type equal(const Any& left, const Any& rhs) const {
|
||||
return dyn_cast<U>(&left) == dyn_cast<U>(&rhs);
|
||||
}
|
||||
|
||||
bool operator==(const Any& rhs) const override {
|
||||
return rhs.is(typeid(T)) && equal<T>(*this, rhs);
|
||||
}
|
||||
|
||||
template <class U, typename std::enable_if<!HasOutputStreamOperator<U>::value, bool>::type = true>
|
||||
void print(std::ostream& stream, const U& object) const {}
|
||||
|
||||
template <class U, typename std::enable_if<HasOutputStreamOperator<U>::value, bool>::type = true>
|
||||
void print(std::ostream& stream, const U& object) const {
|
||||
stream << object;
|
||||
}
|
||||
|
||||
void print(std::ostream& stream) const override {
|
||||
print<T>(stream, get());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static T& dyn_cast(Any* obj) {
|
||||
if (obj == nullptr)
|
||||
IE_THROW() << "Parameter is empty!";
|
||||
return dynamic_cast<RealData<T>&>(*obj).get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static const T& dyn_cast(const Any* obj) {
|
||||
if (obj == nullptr)
|
||||
IE_THROW() << "Parameter is empty!";
|
||||
return dynamic_cast<const RealData<T>&>(*obj).get();
|
||||
}
|
||||
|
||||
Any* ptr = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief An std::map object containing parameters
|
||||
*/
|
||||
using ParamMap = std::map<std::string, Parameter>;
|
||||
namespace ov {
|
||||
namespace runtime {
|
||||
|
||||
#ifdef __ANDROID__
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<InferenceEngine::Blob::Ptr>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<int>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<bool>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<float>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<uint32_t>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::string>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<unsigned long>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::vector<int>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::vector<std::string>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::vector<unsigned long>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(
|
||||
InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(
|
||||
InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>);
|
||||
#endif
|
||||
|
||||
} // namespace InferenceEngine
|
||||
} // namespace runtime
|
||||
} // namespace ov
|
||||
|
@ -15,11 +15,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "executable_network.hpp"
|
||||
#include "ie_plugin_config.hpp"
|
||||
#include "ie_version.hpp"
|
||||
#include "remote_context.hpp"
|
||||
#include "openvino/runtime/common.hpp"
|
||||
#include "openvino/runtime/executable_network.hpp"
|
||||
#include "openvino/runtime/remote_context.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
class IExtension;
|
||||
@ -213,7 +213,7 @@ public:
|
||||
* @param name - config key.
|
||||
* @return Value of config corresponding to config key.
|
||||
*/
|
||||
ie::Parameter get_config(const std::string& deviceName, const std::string& name) const;
|
||||
Parameter get_config(const std::string& deviceName, const std::string& name) const;
|
||||
|
||||
/**
|
||||
* @brief Gets general runtime metric for dedicated hardware.
|
||||
@ -225,7 +225,7 @@ public:
|
||||
* @param name - metric name to request.
|
||||
* @return Metric value corresponding to metric key.
|
||||
*/
|
||||
ie::Parameter get_metric(const std::string& deviceName, const std::string& name) const;
|
||||
Parameter get_metric(const std::string& deviceName, const std::string& name) const;
|
||||
|
||||
/**
|
||||
* @brief Returns devices available for neural networks inference
|
||||
@ -292,7 +292,7 @@ public:
|
||||
* @param params Map of device-specific shared context parameters.
|
||||
* @return A shared pointer to a created remote context.
|
||||
*/
|
||||
RemoteContext create_context(const std::string& deviceName, const ie::ParamMap& params);
|
||||
RemoteContext create_context(const std::string& deviceName, const ParamMap& params);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to default(plugin-supplied) shared context object for specified accelerator device.
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ie_parameter.hpp"
|
||||
#include "openvino/core/function.hpp"
|
||||
#include "openvino/runtime/infer_request.hpp"
|
||||
#include "openvino/runtime/parameter.hpp"
|
||||
#include "openvino/runtime/remote_context.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
@ -96,7 +96,7 @@ public:
|
||||
*
|
||||
* @param config Map of pairs: (config parameter name, config parameter value)
|
||||
*/
|
||||
void set_config(const ie::ParamMap& config);
|
||||
void set_config(const ParamMap& config);
|
||||
|
||||
/** @brief Gets configuration for current executable network.
|
||||
*
|
||||
@ -109,7 +109,7 @@ public:
|
||||
* @param name config key, can be found in ie_plugin_config.hpp
|
||||
* @return Configuration parameter value
|
||||
*/
|
||||
ie::Parameter get_config(const std::string& name) const;
|
||||
Parameter get_config(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* @brief Gets general runtime metric for an executable network.
|
||||
@ -120,7 +120,7 @@ public:
|
||||
* @param name metric name to request
|
||||
* @return Metric parameter value
|
||||
*/
|
||||
ie::Parameter get_metric(const std::string& name) const;
|
||||
Parameter get_metric(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* @brief Returns pointer to plugin-specific shared context
|
||||
|
@ -5,7 +5,7 @@
|
||||
/**
|
||||
* @brief A header file that provides wrapper classes for infer requests and callbacks.
|
||||
*
|
||||
* @file infer_request.hpp
|
||||
* @file openvino/runtime/infer_request.hpp
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "profiling_info.hpp"
|
||||
#include "variable_state.hpp"
|
||||
#include "openvino/runtime/common.hpp"
|
||||
#include "openvino/runtime/profiling_info.hpp"
|
||||
#include "openvino/runtime/variable_state.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
class IInferRequestInternal;
|
||||
|
@ -0,0 +1,362 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief A header file for the Parameter class
|
||||
* @file openvino/runtime/parameter.hpp
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <typeinfo>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "ie_api.h"
|
||||
#include "openvino/core/except.hpp"
|
||||
|
||||
namespace ov {
|
||||
|
||||
namespace runtime {
|
||||
|
||||
/**
|
||||
* @brief This class represents an object to work with different parameters
|
||||
*
|
||||
*/
|
||||
class INFERENCE_ENGINE_API_CLASS(Parameter) {
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*/
|
||||
Parameter() = default;
|
||||
|
||||
/**
|
||||
* @brief Move constructor
|
||||
*
|
||||
* @param parameter Parameter object
|
||||
*/
|
||||
Parameter(Parameter&& parameter) noexcept {
|
||||
std::swap(ptr, parameter.ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy constructor
|
||||
*
|
||||
* @param parameter Parameter object
|
||||
*/
|
||||
Parameter(const Parameter& parameter) {
|
||||
*this = parameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructor creates parameter with object
|
||||
*
|
||||
* @tparam T Parameter type
|
||||
* @tparam U Identity type-transformation
|
||||
* @param parameter object
|
||||
*/
|
||||
template <class T,
|
||||
typename = typename std::enable_if<!std::is_same<typename std::decay<T>::type, Parameter>::value &&
|
||||
!std::is_abstract<typename std::decay<T>::type>::value>::type>
|
||||
Parameter(T&& parameter) {
|
||||
static_assert(!std::is_same<typename std::decay<T>::type, Parameter>::value, "To prevent recursion");
|
||||
ptr = new RealData<typename std::decay<T>::type>(std::forward<T>(parameter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructor creates string parameter from char *
|
||||
*
|
||||
* @param str char array
|
||||
*/
|
||||
Parameter(const char* str) : Parameter(std::string(str)) {}
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~Parameter();
|
||||
|
||||
/**
|
||||
* Copy operator for Parameter
|
||||
* @param parameter Parameter object
|
||||
* @return Parameter
|
||||
*/
|
||||
Parameter& operator=(const Parameter& parameter) {
|
||||
if (this == ¶meter) {
|
||||
return *this;
|
||||
}
|
||||
clear();
|
||||
if (!parameter.empty())
|
||||
ptr = parameter.ptr->copy();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a value from parameter
|
||||
*/
|
||||
void clear() {
|
||||
delete ptr;
|
||||
ptr = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that parameter contains a value
|
||||
* @return false if parameter contains a value else false
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
return nullptr == ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the type of value
|
||||
* @tparam T Type of value
|
||||
* @return true if type of value is correct
|
||||
*/
|
||||
template <class T>
|
||||
bool is() const {
|
||||
return empty() ? false : ptr->is(typeid(T));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <typename T>
|
||||
T&& as() && {
|
||||
return std::move(dyn_cast<T>(ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
T& as() & {
|
||||
return dyn_cast<T>(ptr);
|
||||
}
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
const T& as() const& {
|
||||
return dyn_cast<T>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator T &&() && {
|
||||
return std::move(dyn_cast<typename std::remove_cv<T>::type>(ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator T&() & {
|
||||
return dyn_cast<typename std::remove_cv<T>::type>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator const T&() const& {
|
||||
return dyn_cast<typename std::remove_cv<T>::type>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic cast to specified type
|
||||
* @tparam T type
|
||||
* @return casted object
|
||||
*/
|
||||
template <class T>
|
||||
operator T&() const& {
|
||||
return dyn_cast<typename std::remove_cv<T>::type>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The comparison operator for the Parameter
|
||||
*
|
||||
* @param rhs object to compare
|
||||
* @return true if objects are equal
|
||||
*/
|
||||
bool operator==(const Parameter& rhs) const {
|
||||
return *ptr == *(rhs.ptr);
|
||||
}
|
||||
/**
|
||||
* @brief The comparison operator for the Parameter
|
||||
*
|
||||
* @param rhs object to compare
|
||||
* @return true if objects aren't equal
|
||||
*/
|
||||
bool operator!=(const Parameter& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prints underlying object to the given output stream.
|
||||
* Uses operator<< if it is defined, leaves stream unchanged otherwise.
|
||||
* In case of empty parameter or nullptr stream immediately returns.
|
||||
*
|
||||
* @param object Object to be printed to the given output stream.
|
||||
* @param stream Output stream object will be printed to.
|
||||
*/
|
||||
friend void PrintTo(const Parameter& object, std::ostream* stream) {
|
||||
if (object.empty() || !stream) {
|
||||
return;
|
||||
}
|
||||
object.ptr->print(*stream);
|
||||
}
|
||||
|
||||
private:
|
||||
template <class T, class EqualTo>
|
||||
struct CheckOperatorEqual {
|
||||
template <class U, class V>
|
||||
static auto test(U*) -> decltype(std::declval<U>() == std::declval<V>()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename, typename>
|
||||
static auto test(...) -> std::false_type {
|
||||
return {};
|
||||
}
|
||||
|
||||
using type = typename std::is_same<bool, decltype(test<T, EqualTo>(nullptr))>::type;
|
||||
};
|
||||
|
||||
template <class T, class EqualTo = T>
|
||||
struct HasOperatorEqual : CheckOperatorEqual<T, EqualTo>::type {};
|
||||
|
||||
template <class T, class U>
|
||||
struct CheckOutputStreamOperator {
|
||||
template <class V, class W>
|
||||
static auto test(W*) -> decltype(std::declval<V&>() << std::declval<W>(), std::true_type()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename, typename>
|
||||
static auto test(...) -> std::false_type {
|
||||
return {};
|
||||
}
|
||||
|
||||
using type = typename std::is_same<std::true_type, decltype(test<T, U>(nullptr))>::type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct HasOutputStreamOperator : CheckOutputStreamOperator<std::ostream, T>::type {};
|
||||
|
||||
struct Any {
|
||||
#ifdef __ANDROID__
|
||||
virtual ~Any();
|
||||
#else
|
||||
virtual ~Any() = default;
|
||||
#endif
|
||||
virtual bool is(const std::type_info&) const = 0;
|
||||
virtual Any* copy() const = 0;
|
||||
virtual bool operator==(const Any& rhs) const = 0;
|
||||
virtual void print(std::ostream&) const = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct RealData : Any, std::tuple<T> {
|
||||
using std::tuple<T>::tuple;
|
||||
|
||||
bool is(const std::type_info& id) const override {
|
||||
return id == typeid(T);
|
||||
}
|
||||
Any* copy() const override {
|
||||
return new RealData{get()};
|
||||
}
|
||||
|
||||
T& get() & {
|
||||
return std::get<0>(*static_cast<std::tuple<T>*>(this));
|
||||
}
|
||||
|
||||
const T& get() const& {
|
||||
return std::get<0>(*static_cast<const std::tuple<T>*>(this));
|
||||
}
|
||||
|
||||
template <class U>
|
||||
typename std::enable_if<!HasOperatorEqual<U>::value, bool>::type equal(const Any& left, const Any& rhs) const {
|
||||
throw ov::Exception("Parameter doesn't contain equal operator");
|
||||
}
|
||||
|
||||
template <class U>
|
||||
typename std::enable_if<HasOperatorEqual<U>::value, bool>::type equal(const Any& left, const Any& rhs) const {
|
||||
return dyn_cast<U>(&left) == dyn_cast<U>(&rhs);
|
||||
}
|
||||
|
||||
bool operator==(const Any& rhs) const override {
|
||||
return rhs.is(typeid(T)) && equal<T>(*this, rhs);
|
||||
}
|
||||
|
||||
template <class U, typename std::enable_if<!HasOutputStreamOperator<U>::value, bool>::type = true>
|
||||
void print(std::ostream& stream, const U& object) const {}
|
||||
|
||||
template <class U, typename std::enable_if<HasOutputStreamOperator<U>::value, bool>::type = true>
|
||||
void print(std::ostream& stream, const U& object) const {
|
||||
stream << object;
|
||||
}
|
||||
|
||||
void print(std::ostream& stream) const override {
|
||||
print<T>(stream, get());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static T& dyn_cast(Any* obj) {
|
||||
OPENVINO_ASSERT(obj != nullptr, "Parameter is empty!");
|
||||
return dynamic_cast<RealData<T>&>(*obj).get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static const T& dyn_cast(const Any* obj) {
|
||||
OPENVINO_ASSERT(obj != nullptr, "Parameter is empty!");
|
||||
return dynamic_cast<const RealData<T>&>(*obj).get();
|
||||
}
|
||||
|
||||
Any* ptr = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief An std::map object containing parameters
|
||||
*/
|
||||
using ParamMap = std::map<std::string, Parameter>;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<int>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<bool>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<float>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<uint32_t>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<std::string>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<unsigned long>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<std::vector<int>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<std::vector<std::string>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(ov::runtime::Parameter::RealData<std::vector<unsigned long>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(
|
||||
ov::runtime::Parameter::RealData<std::tuple<unsigned int, unsigned int>>);
|
||||
extern template struct INFERENCE_ENGINE_API_CLASS(
|
||||
ov::runtime::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>);
|
||||
#endif
|
||||
|
||||
} // namespace runtime
|
||||
|
||||
} // namespace ov
|
@ -13,10 +13,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "details/ie_so_loader.h"
|
||||
#include "ie_parameter.hpp"
|
||||
#include "ie_remote_context.hpp"
|
||||
#include "openvino/runtime/common.hpp"
|
||||
#include "openvino/runtime/parameter.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
class RemoteBlob;
|
||||
@ -120,7 +119,7 @@ public:
|
||||
* Abstract method.
|
||||
* @return A pointer to plugin object that implements RemoteBlob interface.
|
||||
*/
|
||||
std::shared_ptr<ie::RemoteBlob> create_blob(const ie::TensorDesc& tensorDesc, const ie::ParamMap& params = {});
|
||||
std::shared_ptr<ie::RemoteBlob> create_blob(const ie::TensorDesc& tensorDesc, const ParamMap& params = {});
|
||||
|
||||
/**
|
||||
* @brief Returns a map of device-specific parameters required for low-level
|
||||
@ -131,7 +130,7 @@ public:
|
||||
* Abstract method.
|
||||
* @return A map of name/parameter elements.
|
||||
*/
|
||||
ie::ParamMap get_params() const;
|
||||
ParamMap get_params() const;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
|
@ -10,6 +10,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "openvino/runtime/core.hpp"
|
||||
#include "openvino/runtime/executable_network.hpp"
|
||||
#include "openvino/runtime/infer_request.hpp"
|
||||
#include "openvino/runtime/profiling_info.hpp"
|
||||
|
@ -5,7 +5,7 @@
|
||||
/**
|
||||
* @brief A header file that provides VariableState
|
||||
*
|
||||
* @file variable_state.hpp
|
||||
* @file openvino/runtime/variable_state.hpp
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -16,7 +16,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "openvino/runtime/common.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
class IVariableStateInternal;
|
||||
|
@ -127,32 +127,6 @@ StatusCode InferenceEngineException::getStatus() const {
|
||||
} // namespace details
|
||||
IE_SUPPRESS_DEPRECATED_END
|
||||
|
||||
//
|
||||
// ie_parameter.hpp
|
||||
//
|
||||
|
||||
Parameter::~Parameter() {
|
||||
clear();
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
Parameter::Any::~Any() {}
|
||||
|
||||
template struct Parameter::RealData<int>;
|
||||
template struct Parameter::RealData<bool>;
|
||||
template struct Parameter::RealData<float>;
|
||||
template struct Parameter::RealData<double>;
|
||||
template struct Parameter::RealData<uint32_t>;
|
||||
template struct Parameter::RealData<std::string>;
|
||||
template struct Parameter::RealData<unsigned long>;
|
||||
template struct Parameter::RealData<std::vector<int>>;
|
||||
template struct Parameter::RealData<std::vector<std::string>>;
|
||||
template struct Parameter::RealData<std::vector<unsigned long>>;
|
||||
template struct Parameter::RealData<std::tuple<unsigned int, unsigned int>>;
|
||||
template struct Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>;
|
||||
template struct Parameter::RealData<Blob::Ptr>;
|
||||
#endif
|
||||
|
||||
//
|
||||
// ie_blob.h
|
||||
//
|
||||
@ -178,3 +152,37 @@ template class INFERENCE_ENGINE_API_CLASS(TBlob<bool>);
|
||||
template class INFERENCE_ENGINE_API_CLASS(TBlob<char>);
|
||||
|
||||
} // namespace InferenceEngine
|
||||
|
||||
namespace ov {
|
||||
|
||||
namespace runtime {
|
||||
|
||||
//
|
||||
// openvino/runtime/parameter.hpp
|
||||
//
|
||||
|
||||
Parameter::~Parameter() {
|
||||
clear();
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
Parameter::Any::~Any() {}
|
||||
|
||||
template struct Parameter::RealData<InferenceEngine::Blob::Ptr>;
|
||||
template struct Parameter::RealData<int>;
|
||||
template struct Parameter::RealData<bool>;
|
||||
template struct Parameter::RealData<float>;
|
||||
template struct Parameter::RealData<double>;
|
||||
template struct Parameter::RealData<uint32_t>;
|
||||
template struct Parameter::RealData<std::string>;
|
||||
template struct Parameter::RealData<unsigned long>;
|
||||
template struct Parameter::RealData<std::vector<int>>;
|
||||
template struct Parameter::RealData<std::vector<std::string>>;
|
||||
template struct Parameter::RealData<std::vector<unsigned long>>;
|
||||
template struct Parameter::RealData<std::tuple<unsigned int, unsigned int>>;
|
||||
template struct Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>;
|
||||
#endif
|
||||
|
||||
} // namespace runtime
|
||||
|
||||
} // namespace ov
|
||||
|
@ -1358,7 +1358,7 @@ void Core::set_config(const ConfigMap& config, const std::string& deviceName) {
|
||||
});
|
||||
}
|
||||
|
||||
ie::Parameter Core::get_config(const std::string& deviceName, const std::string& name) const {
|
||||
Parameter Core::get_config(const std::string& deviceName, const std::string& name) const {
|
||||
OPENVINO_ASSERT(deviceName.find("HETERO:") != 0,
|
||||
"You can only get_config of the HETERO itself (without devices). "
|
||||
"get_config is also possible for the individual devices before creating the HETERO on top.");
|
||||
@ -1378,7 +1378,7 @@ ie::Parameter Core::get_config(const std::string& deviceName, const std::string&
|
||||
return copyParameterValue(_impl->GetCPPPluginByName(parsed._deviceName).get_config(name, parsed._config)););
|
||||
}
|
||||
|
||||
ie::Parameter Core::get_metric(const std::string& deviceName, const std::string& name) const {
|
||||
Parameter Core::get_metric(const std::string& deviceName, const std::string& name) const {
|
||||
OV_CORE_CALL_STATEMENT(return _impl->GetMetric(deviceName, name););
|
||||
}
|
||||
|
||||
@ -1400,7 +1400,7 @@ void Core::register_plugins(const std::string& xmlConfigFile) {
|
||||
OV_CORE_CALL_STATEMENT(_impl->RegisterPluginsInRegistry(xmlConfigFile););
|
||||
}
|
||||
|
||||
RemoteContext Core::create_context(const std::string& deviceName, const ie::ParamMap& params) {
|
||||
RemoteContext Core::create_context(const std::string& deviceName, const ParamMap& params) {
|
||||
OPENVINO_ASSERT(deviceName.find("HETERO") != 0, "HETERO device does not support remote context");
|
||||
OPENVINO_ASSERT(deviceName.find("MULTI") != 0, "MULTI device does not support remote context");
|
||||
OPENVINO_ASSERT(deviceName.find("AUTO") != 0, "AUTO device does not support remote context");
|
||||
@ -1416,7 +1416,7 @@ RemoteContext Core::get_default_context(const std::string& deviceName) {
|
||||
OPENVINO_ASSERT(deviceName.find("MULTI") != 0, "MULTI device does not support remote context");
|
||||
OPENVINO_ASSERT(deviceName.find("AUTO") != 0, "AUTO device does not support remote context");
|
||||
|
||||
OV_CORE_CALL_STATEMENT(auto parsed = parseDeviceNameIntoConfig(deviceName, ie::ParamMap());
|
||||
OV_CORE_CALL_STATEMENT(auto parsed = parseDeviceNameIntoConfig(deviceName, ParamMap());
|
||||
auto remoteContext =
|
||||
_impl->GetCPPPluginByName(parsed._deviceName).get_default_context(parsed._config);
|
||||
return {remoteContext._so, remoteContext._ptr};);
|
||||
|
@ -104,7 +104,7 @@ void pre_calc_for_bilinear_interpolate(
|
||||
T hy = static_cast<T>(1) - ly, hx = static_cast<T>(1) - lx;
|
||||
T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx;
|
||||
|
||||
// save weights and indeces
|
||||
// save weights and indices
|
||||
PreCalc<T> pc;
|
||||
pc.pos1 = y_low * width + x_low;
|
||||
pc.pos2 = y_low * width + x_high;
|
||||
@ -175,7 +175,7 @@ void ROIAlignForward_cpu_kernel(
|
||||
// We do average (integral) pooling inside a bin
|
||||
const T count = static_cast<T>(roi_bin_grid_h * roi_bin_grid_w); // e.g. = 4
|
||||
|
||||
// we want to precalculate indeces and weights shared by all chanels,
|
||||
// we want to precalculate indices and weights shared by all chanels,
|
||||
// this is the key point of optimiation
|
||||
std::vector<PreCalc<T>> pre_calc(
|
||||
roi_bin_grid_h * roi_bin_grid_w * pooled_width * pooled_height);
|
||||
|
@ -433,7 +433,7 @@ public:
|
||||
// Convert from packed format to array of dimensions from minor to major.
|
||||
DimVector toPermutation() const;
|
||||
|
||||
// Get memory indeces for each dimension.
|
||||
// Get memory indices for each dimension.
|
||||
DimValues toIndices() const;
|
||||
|
||||
//
|
||||
|
@ -275,10 +275,10 @@ TEST_F(ParameterTests, CompareParametersWithoutEqualOperator) {
|
||||
Parameter parB = b;
|
||||
Parameter parC = c;
|
||||
|
||||
ASSERT_THROW((void)(parA == parB), Exception);
|
||||
ASSERT_THROW((void)(parA != parB), Exception);
|
||||
ASSERT_THROW((void)(parA == parC), Exception);
|
||||
ASSERT_THROW((void)(parA != parC), Exception);
|
||||
ASSERT_THROW((void)(parA == parB), ov::Exception);
|
||||
ASSERT_THROW((void)(parA != parB), ov::Exception);
|
||||
ASSERT_THROW((void)(parA == parC), ov::Exception);
|
||||
ASSERT_THROW((void)(parA != parC), ov::Exception);
|
||||
}
|
||||
|
||||
TEST_F(ParameterTests, ParameterRemovedRealObject) {
|
||||
|
@ -1944,7 +1944,7 @@ namespace internal {
|
||||
T hy = static_cast<T>(1) - ly, hx = static_cast<T>(1) - lx;
|
||||
T w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx;
|
||||
|
||||
// save weights and indeces
|
||||
// save weights and indices
|
||||
PreCalc<T> pc;
|
||||
pc.pos1 = y_low * width + x_low;
|
||||
pc.pos2 = y_low * width + x_high;
|
||||
@ -2014,7 +2014,7 @@ namespace internal {
|
||||
// We do average (integral) pooling inside a bin
|
||||
const T count = static_cast<T>(roi_bin_grid_h * roi_bin_grid_w); // e.g. = 4
|
||||
|
||||
// we want to precalculate indeces and weights shared by all chanels,
|
||||
// we want to precalculate indices and weights shared by all chanels,
|
||||
// this is the key point of optimiation
|
||||
std::vector<PreCalc<T>> pre_calc(
|
||||
roi_bin_grid_h * roi_bin_grid_w * pooled_width * pooled_height);
|
||||
@ -2302,7 +2302,7 @@ namespace internal {
|
||||
// We do average (integral) pooling inside a bin
|
||||
const T count = static_cast<T>(roi_bin_grid_h * roi_bin_grid_w); // e.g. = 4
|
||||
|
||||
// we want to precalculate indeces and weights shared by all chanels,
|
||||
// we want to precalculate indices and weights shared by all chanels,
|
||||
// this is the key point of optimiation
|
||||
std::vector<PreCalc<T>> pre_calc(
|
||||
roi_bin_grid_h * roi_bin_grid_w * pooled_width * pooled_height);
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
/// \brief Structure that specifies attributes for interpolation
|
||||
struct Attributes {
|
||||
// specify dimension indices where interpolation is applied, and `axes` is any
|
||||
// unordered list of indeces of different dimensions of input tensor. Required.
|
||||
// unordered list of indices of different dimensions of input tensor. Required.
|
||||
AxisSet axes;
|
||||
// specifies type of interpolation
|
||||
// one of `nearest`, `linear`, `cubic`, `area`. Required.
|
||||
|
Loading…
Reference in New Issue
Block a user