Import initialization graph in SignatureDef SavedModels as an MLIR function in
TF saved model dialect.
-Mark the init function referenced by SessionInitializerOp as an exported
function with the reserved name "__tf_saved_model_session_initializer".
-Remove variable init logic in init function if it is already imported as a global tensor.
-Add a canonicalizer to SessionInitializerOp to remove empty init functions.
-Return error on SessionInitializerOp in IREE compiler pipeline.
PiperOrigin-RevId: 317395165
diff --git a/integrations/tensorflow/compiler/TFSavedModelLowerGlobalTensors.cpp b/integrations/tensorflow/compiler/TFSavedModelLowerGlobalTensors.cpp
index 0cca1b1..6d8271d 100644
--- a/integrations/tensorflow/compiler/TFSavedModelLowerGlobalTensors.cpp
+++ b/integrations/tensorflow/compiler/TFSavedModelLowerGlobalTensors.cpp
@@ -60,6 +60,10 @@
OpBuilder globalBuilder(module.getBodyRegion());
SymbolTable symbolTable(module);
+ if (auto sessionInitializer = tf_saved_model::GetSessionInitializerOp(module))
+ return sessionInitializer.emitError()
+ << "Session initializer is not supported yet";
+
DenseMap<StringRef, std::string> symNameToFlowSymName;
for (auto globalTensor : module.getOps<tf_saved_model::GlobalTensorOp>()) {
auto exportedNames = tf_saved_model::GetExportedNames(globalTensor);