36 class INFERENCE_ENGINE_API_CLASS(Parameter) {
48 std::swap(ptr, parameter.ptr);
57 Parameter(
const std::shared_ptr<ngraph::Variant>& var);
74 typename =
typename std::enable_if<!std::is_same<typename std::decay<T>::type,
Parameter>::value>::type>
76 static_assert(!std::is_same<
typename std::decay<T>::type,
Parameter>::value,
"To prevent recursion");
77 ptr =
new RealData<typename std::decay<T>::type>(std::forward<T>(parameter));
97 if (
this == ¶meter) {
101 if (!parameter.
empty()) ptr = parameter.ptr->copy();
118 return nullptr == ptr;
128 return empty() ?
false : ptr->is(
typeid(T));
136 template <
typename T>
138 return std::move(dyn_cast<T>(ptr));
148 return dyn_cast<T>(ptr);
156 const T&
as() const& {
157 return dyn_cast<T>(ptr);
167 return std::move(dyn_cast<
typename std::remove_cv<T>::type>(ptr));
177 return dyn_cast<
typename std::remove_cv<T>::type>(ptr);
186 operator const T&()
const& {
187 return dyn_cast<
typename std::remove_cv<T>::type>(ptr);
195 std::shared_ptr<ngraph::Variant> asVariant()
const;
202 operator std::shared_ptr<ngraph::Variant>()
const {
212 operator T&()
const& {
213 return dyn_cast<
typename std::remove_cv<T>::type>(ptr);
222 return *ptr == *(rhs.ptr);
230 return !(*
this == rhs);
234 template <
class T,
class EqualTo>
235 struct CheckOperatorEqual {
236 template <
class U,
class V>
237 static auto test(U*) -> decltype(std::declval<U>() == std::declval<V>()) {
241 template <
typename,
typename>
242 static auto test(...) -> std::false_type {
246 using type =
typename std::is_same<bool, decltype(test<T, EqualTo>(
nullptr))>::type;
249 template <
class T,
class EqualTo = T>
250 struct HasOperatorEqual : CheckOperatorEqual<T, EqualTo>::type {};
256 virtual ~Any() =
default;
258 virtual bool is(
const std::type_info&)
const = 0;
259 virtual Any* copy()
const = 0;
260 virtual bool operator==(
const Any& rhs)
const = 0;
264 struct RealData : Any, std::tuple<T> {
265 using std::tuple<T>::tuple;
267 bool is(
const std::type_info&
id)
const override {
268 return id ==
typeid(T);
270 Any* copy()
const override {
271 return new RealData {
get()};
275 return std::get<0>(*
static_cast<std::tuple<T>*
>(
this));
278 const T&
get()
const& {
279 return std::get<0>(*
static_cast<const std::tuple<T>*
>(
this));
283 typename std::enable_if<!HasOperatorEqual<U>::value,
bool>::type equal(
const Any& left,
const Any& rhs)
const {
288 typename std::enable_if<HasOperatorEqual<U>::value,
bool>::type equal(
const Any& left,
const Any& rhs)
const {
289 return dyn_cast<U>(&left) == dyn_cast<U>(&rhs);
292 bool operator==(
const Any& rhs)
const override {
293 return rhs.is(
typeid(T)) && equal<T>(*
this, rhs);
297 template <
typename T>
298 static T& dyn_cast(Any* obj) {
300 return dynamic_cast<RealData<T>&
>(*obj).get();
303 template <
typename T>
304 static const T& dyn_cast(
const Any* obj) {
306 return dynamic_cast<const RealData<T>&
>(*obj).get();
313 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<int>);
314 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<bool>);
315 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<float>);
316 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<uint32_t>);
317 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::string>);
318 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<unsigned long>);
319 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::vector<int>>);
320 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::vector<std::string>>);
321 extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData<std::vector<unsigned long>>);
322 extern template struct INFERENCE_ENGINE_API_CLASS(
323 InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int>>);
324 extern template struct INFERENCE_ENGINE_API_CLASS(
325 InferenceEngine::Parameter::RealData<std::tuple<unsigned int, unsigned int, unsigned int>>);
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:24
Parameter(T &¶meter)
Constructor creates parameter with object.
Definition: ie_parameter.hpp:75
bool is() const
Definition: ie_parameter.hpp:127
Inference Engine API.
Definition: ie_argmax_layer.hpp:11
Parameter(Parameter &¶meter) noexcept
Move constructor.
Definition: ie_parameter.hpp:47
T & as() &
Definition: ie_parameter.hpp:147
Parameter(const Parameter ¶meter)
Copy constructor.
Definition: ie_parameter.hpp:63
bool operator==(const Parameter &rhs) const
The comparison operator for the Parameter.
Definition: ie_parameter.hpp:221
void clear()
Definition: ie_parameter.hpp:108
bool empty() const noexcept
Definition: ie_parameter.hpp:117
Definition: ie_cnn_network.h:26
Parameter & operator=(const Parameter ¶meter)
Definition: ie_parameter.hpp:96
const T & as() const &
Definition: ie_parameter.hpp:156
Parameter(const char *str)
Constructor creates string parameter from char *.
Definition: ie_parameter.hpp:84
T && as() &&
Definition: ie_parameter.hpp:137
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
bool operator!=(const Parameter &rhs) const
The comparison operator for the Parameter.
Definition: ie_parameter.hpp:229
This class represents an object to work with different parameters.
Definition: ie_parameter.hpp:36
A header file for the main Inference Engine exception.