diff --git a/src/Builder/FrontendDialectTransformer.cpp b/src/Builder/FrontendDialectTransformer.cpp index fc06081..c03c9f8 100644 --- a/src/Builder/FrontendDialectTransformer.cpp +++ b/src/Builder/FrontendDialectTransformer.cpp @@ -485,18 +485,24 @@ private: buildOutputAndOperation(node, in, nIn, nOut); } + void ImportCustomNode(const onnx::NodeProto &node) { + llvm::StringRef opName = node.op_type(); + + mlir::emitWarning(UnknownLoc(), "Could not find op importer: assuming this " + "represents a custom operator."); + } + void ImportNode(const onnx::NodeProto &node) { llvm::StringRef opName = node.op_type(); - // the following code is generated by gen_doc.py - // refer to Dialect/ONNX/ONNXOps.td for details - // when the input or output of then op does not match the specification, - // the generic operator is used - // one known reeason is the optional input - - auto found = import_handler_map_.find(opName.str()); - assert(found != import_handler_map_.end() && "Could not find op importer"); - (this->*(found->second))(node); + // look up handler for the opName. If not found, create a node + // for a custom op, and issue a warning. + auto handler = import_handler_map_.find(opName.str()); + if (handler != import_handler_map_.end()) { + (this->*(handler->second))(node); + } else { + ImportCustomNode(node); + } } void InitHandlerMap() {