initial code for handling custom ops (#288)

* initial code for handling custom ops

* format
This commit is contained in:
Kevin O'Brien 2020-09-11 10:49:15 -04:00 committed by GitHub
parent ac67900baf
commit 1fcf97ef8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 9 deletions

View File

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