| 122 | } |
| 123 | |
| 124 | std::string ExperimentalRunPassPipeline(const std::string &mlir_txt, |
| 125 | const std::string &pass_pipeline, |
| 126 | bool show_debug_info, |
| 127 | TF_Status *status) { |
| 128 | mlir::MLIRContext context; |
| 129 | mlir::OwningModuleRef module; |
| 130 | { |
| 131 | mlir::StatusScopedDiagnosticHandler diagnostic_handler(&context); |
| 132 | module = mlir::parseSourceString(mlir_txt, &context); |
| 133 | if (!module) { |
| 134 | Set_TF_Status_from_Status(status, diagnostic_handler.ConsumeStatus()); |
| 135 | return "// error"; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | // Run the pass_pipeline on the module. |
| 140 | mlir::PassManager pm(&context); |
| 141 | std::string error; |
| 142 | llvm::raw_string_ostream error_stream(error); |
| 143 | if (failed(mlir::parsePassPipeline(pass_pipeline, pm, error_stream))) { |
| 144 | TF_SetStatus(status, TF_INVALID_ARGUMENT, |
| 145 | ("Invalid pass_pipeline: " + error_stream.str()).c_str()); |
| 146 | return "// error"; |
| 147 | } |
| 148 | |
| 149 | mlir::StatusScopedDiagnosticHandler diagnostic_handler(&context); |
| 150 | if (failed(pm.run(*module))) { |
| 151 | Set_TF_Status_from_Status(status, diagnostic_handler.ConsumeStatus()); |
| 152 | return "// error"; |
| 153 | } |
| 154 | return MlirModuleToString(*module, show_debug_info); |
| 155 | } |
| 156 | |
| 157 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected