}
}
+/**
+ * @brief If domain is empty string or onnx.ai, it is default domain
+ * @param [in] domain The name of domain
+ * @return Whether it is default domain or not
+ */
+bool is_default_domain(const std::string domain)
+{
+ return (domain.compare("") == 0 || domain.compare("onnx.ai") == 0);
+}
+
void convert_graph(::onnx::ModelProto &onnx_model_proto, loco::Graph *graph)
{
auto nodes = stdex::make_unique<moco::onnx::SymbolTable>();
assert(onnx_model_proto.has_graph());
::onnx::GraphProto onnx_graph_proto = onnx_model_proto.graph();
+ /// All nodes in the ModelProto's graph will bind against the operator
+ /// with the same-domain/same-op_type operator with the HIGHEST version
+ /// in the referenced operator sets.
+ assert(onnx_model_proto.opset_import_size() > 0);
+ int64_t opset_version = 1;
+ for (int i = 0; i < onnx_model_proto.opset_import_size(); ++i)
+ {
+ auto opset = onnx_model_proto.opset_import(i);
+
+ if (!opset.has_domain() || is_default_domain(opset.domain()))
+ {
+ if (opset.version() > opset_version)
+ {
+ opset_version = opset.version();
+ }
+ }
+ else
+ {
+ throw std::runtime_error("Not supported for custom operation");
+ }
+ }
+
// 1. Convert all the nodes to loco::Node
for (const auto &n : onnx_graph_proto.node())
{