From 89310df4bc576ee951b0d86fe61035e990483a2b Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Wed, 30 Dec 2020 12:37:58 -0800 Subject: [PATCH] Emit warning for op not modeled in dialect. Unmodeled ops are treated very conservatively. Until the dialect fallback hook for querying effects is completed, these will all be marked as having side-effects. Warn for unmodeled op types. PiperOrigin-RevId: 349589705 Change-Id: If3b4621050c5e53f773f8a518caf2c32ddbc7328 --- .../mlir/tensorflow/translate/import_model.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tensorflow/compiler/mlir/tensorflow/translate/import_model.cc b/tensorflow/compiler/mlir/tensorflow/translate/import_model.cc index 56c2c04e8da..8d7e764f64d 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/import_model.cc +++ b/tensorflow/compiler/mlir/tensorflow/translate/import_model.cc @@ -440,6 +440,9 @@ class ImporterBase { protected: // Maps feed as TensorId to new Placeholder node name. absl::flat_hash_map remapped_feeds_; + + // All the TF ops encountered that aren't modelled in dialect. + llvm::DenseSet unmodelled_op_types_; }; // Returns true if the node with given name has a non primary output that is @@ -1784,6 +1787,19 @@ mlir::Operation* ImporterBase::CreateOperation( } } + mlir::OperationName name = inner_op->getName(); + if (!name.getAbstractOperation() && + // Skip unmodelled ops that are handled differently. + (node_type_name != "_Arg" && node_type_name != "_Retval")) { + if (unmodelled_op_types_.insert(name.getIdentifier()).second) { + LOG(WARNING) << "Unmodelled op type `" << node.type_string() << "`" + << (node.op_def().is_stateful() + ? " is stateful but effects not modelled" + : " is not stateful but will be treated as such " + "conservatively"); + } + } + // Add the terminator for the island island_builder.create(result.location, inner_op->getResults());