| 268 | } |
| 269 | |
| 270 | Status RunMainOp(const RunOptions& run_options, const string& export_dir, |
| 271 | const MetaGraphDef& meta_graph_def, |
| 272 | const std::vector<AssetFileDef>& asset_file_defs, |
| 273 | Session* session, const string& main_op_key) { |
| 274 | LOG(INFO) << "Running MainOp with key " << main_op_key |
| 275 | << " on SavedModel bundle."; |
| 276 | const auto& collection_def_map = meta_graph_def.collection_def(); |
| 277 | const auto main_op_it = collection_def_map.find(main_op_key); |
| 278 | if (main_op_it != collection_def_map.end()) { |
| 279 | if (main_op_it->second.node_list().value_size() != 1) { |
| 280 | return errors::FailedPrecondition( |
| 281 | strings::StrCat("Expected exactly one main op in : ", export_dir)); |
| 282 | } |
| 283 | std::vector<std::pair<string, Tensor>> inputs; |
| 284 | util::AddAssetsTensorsToInputs(export_dir, asset_file_defs, &inputs); |
| 285 | RunMetadata run_metadata; |
| 286 | const StringPiece main_op_name = main_op_it->second.node_list().value(0); |
| 287 | return util::RunOnce(run_options, inputs, {}, {string(main_op_name)}, |
| 288 | nullptr /* outputs */, &run_metadata, session); |
| 289 | } |
| 290 | return Status::OK(); |
| 291 | } |
| 292 | |
| 293 | Status RunMainOp(const RunOptions& run_options, const string& export_dir, |
| 294 | const MetaGraphDef& meta_graph_def, |
no test coverage detected