Unverified Commit c85ff3b8 authored by Artur Wojcik's avatar Artur Wojcik Committed by GitHub

onnx: flatten operatos bridge hierarchy (#1846)

Signed-off-by: 's avatarArtur Wojcik <artur.wojcik@intel.com>
parent 3167b167
......@@ -62,7 +62,7 @@ namespace ngraph
std::vector<std::shared_ptr<Function>> output_functions;
Model model{model_proto};
Graph graph{model_proto.graph(),
ops_bridge::get_operator_set(model.get_opset_version())};
OperatorsBridge::get_operator_set(model.get_opset_version())};
for (const auto& output : graph.get_outputs())
{
output_functions.emplace_back(std::make_shared<Function>(
......
......@@ -17,6 +17,11 @@
#pragma once
#include <cstdint>
#include <map>
#include <string>
#include <unordered_map>
#include "ngraph/except.hpp"
#include "core/operator_set.hpp"
......@@ -24,11 +29,61 @@ namespace ngraph
{
namespace onnx_import
{
namespace ops_bridge
namespace error
{
struct UnknownOperator : ngraph_error
{
explicit UnknownOperator(const std::string& op_type)
: ngraph_error{"unknown operator: \"" + op_type + "\""}
{
}
};
struct UnsupportedVersion : ngraph_error
{
explicit UnsupportedVersion(std::int64_t version)
: ngraph_error{"unsupported operator set version: " + std::to_string(version)}
{
}
};
} // namespace error
class OperatorsBridge
{
const OperatorSet& get_operator_set(std::int64_t version);
public:
OperatorsBridge(const OperatorsBridge&) = delete;
OperatorsBridge& operator=(const OperatorsBridge&) = delete;
OperatorsBridge(OperatorsBridge&&) = delete;
OperatorsBridge& operator=(OperatorsBridge&&) = delete;
static const OperatorSet& get_operator_set(std::int64_t version)
{
return instance().get_operator_set_version(version);
}
private:
std::unordered_map<std::string, std::map<std::int64_t, Operator>> m_map;
OperatorsBridge();
static const OperatorsBridge& instance()
{
static OperatorsBridge instance;
return instance;
}
} // namespace ops_bridge
const OperatorSet& get_operator_set_version_1() const;
const OperatorSet& get_operator_set_version_2() const;
const OperatorSet& get_operator_set_version_3() const;
const OperatorSet& get_operator_set_version_4() const;
const OperatorSet& get_operator_set_version_5() const;
const OperatorSet& get_operator_set_version_6() const;
const OperatorSet& get_operator_set_version_7() const;
const OperatorSet& get_operator_set_version_8() const;
const OperatorSet& get_operator_set_version_9() const;
const OperatorSet& get_operator_set_version(std::int64_t version) const;
};
} // namespace onnx_import
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment