Fixed RTTI issues for ngraph::Variant (#1258)

This commit is contained in:
Ilya Lavrenov 2020-07-09 06:13:20 +03:00 committed by GitHub
parent 5feeab37d4
commit 1f8a8ab33c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 11 deletions

View File

@ -9,6 +9,11 @@
namespace ngraph {
template <typename T>
VariantImpl<T>::~VariantImpl() { }
template class INFERENCE_ENGINE_API_CLASS(VariantImpl<InferenceEngine::Parameter>);
template <>
class INFERENCE_ENGINE_API_CLASS(VariantWrapper<InferenceEngine::Parameter>) : public VariantImpl<InferenceEngine::Parameter> {
public:

View File

@ -61,6 +61,8 @@ public:
std::vector<std::string> getVectorNames() const;
};
extern template class TRANSFORMATIONS_API VariantImpl<FusedNames>;
template<>
class TRANSFORMATIONS_API VariantWrapper<FusedNames> : public VariantImpl<FusedNames> {
public:

View File

@ -46,6 +46,8 @@ public:
std::string getPrimitivesPriority() const;
};
extern template class TRANSFORMATIONS_API VariantImpl<PrimitivesPriority>;
template<>
class TRANSFORMATIONS_API VariantWrapper<PrimitivesPriority> : public VariantImpl<PrimitivesPriority> {
public:

View File

@ -15,6 +15,11 @@
namespace ngraph {
template <typename T>
VariantImpl<T>::~VariantImpl() { }
template class ngraph::VariantImpl<FusedNames>;
constexpr VariantTypeInfo VariantWrapper<FusedNames>::type_info;
std::string FusedNames::getNames() const {

View File

@ -18,6 +18,11 @@
namespace ngraph {
template <typename T>
VariantImpl<T>::~VariantImpl() { }
template class ngraph::VariantImpl<PrimitivesPriority>;
constexpr VariantTypeInfo VariantWrapper<PrimitivesPriority>::type_info;
std::string PrimitivesPriority::getPrimitivesPriority() const {

View File

@ -21,3 +21,25 @@ using namespace ngraph;
// Define variant for std::string
constexpr VariantTypeInfo VariantWrapper<std::string>::type_info;
constexpr VariantTypeInfo VariantWrapper<int64_t>::type_info;
Variant::~Variant()
{
}
std::shared_ptr<ngraph::Variant> Variant::init(const std::shared_ptr<ngraph::Node>& node)
{
return nullptr;
}
std::shared_ptr<ngraph::Variant> Variant::merge(const ngraph::NodeVector& nodes)
{
return nullptr;
}
template <typename T>
VariantImpl<T>::~VariantImpl()
{
}
template class ngraph::VariantImpl<std::string>;
template class ngraph::VariantImpl<int64_t>;

View File

@ -26,21 +26,14 @@ namespace ngraph
{
using VariantTypeInfo = DiscreteTypeInfo;
class Variant
class NGRAPH_API Variant
{
public:
virtual ~Variant() {}
virtual ~Variant();
virtual const VariantTypeInfo& get_type_info() const = 0;
virtual std::shared_ptr<ngraph::Variant> init(const std::shared_ptr<ngraph::Node>& node)
{
return nullptr;
}
virtual std::shared_ptr<ngraph::Variant> merge(const ngraph::NodeVector& nodes)
{
return nullptr;
}
virtual std::shared_ptr<ngraph::Variant> init(const std::shared_ptr<ngraph::Node>& node);
virtual std::shared_ptr<ngraph::Variant> merge(const ngraph::NodeVector& nodes);
};
template <typename VT>
@ -53,6 +46,9 @@ namespace ngraph
: m_value(value)
{
}
~VariantImpl() override;
const value_type& get() const { return m_value; }
value_type& get() { return m_value; }
void set(const value_type& value) { m_value = value; }
@ -60,6 +56,9 @@ namespace ngraph
value_type m_value;
};
extern template class NGRAPH_API VariantImpl<std::string>;
extern template class NGRAPH_API VariantImpl<int64_t>;
template <typename VT>
class VariantWrapper
{

View File

@ -69,6 +69,11 @@ struct Ship
namespace ngraph
{
template <typename T>
VariantImpl<T>::~VariantImpl()
{
}
template <>
class VariantWrapper<Ship> : public VariantImpl<Ship>
{