| 17 | } |
| 18 | |
| 19 | Status GetAssetFileDefs(const MetaGraphDef& meta_graph_def, |
| 20 | std::vector<AssetFileDef>* asset_file_defs) { |
| 21 | // With SavedModel v2, we write asset file def into metagraph instead of |
| 22 | // collection, so read from metagraph first. |
| 23 | if (meta_graph_def.asset_file_def_size() > 0) { |
| 24 | for (const auto& asset : meta_graph_def.asset_file_def()) { |
| 25 | asset_file_defs->push_back(asset); |
| 26 | } |
| 27 | return Status::OK(); |
| 28 | } |
| 29 | |
| 30 | const auto& collection_def_map = meta_graph_def.collection_def(); |
| 31 | const auto assets_it = collection_def_map.find(kSavedModelAssetsKey); |
| 32 | if (assets_it == collection_def_map.end()) { |
| 33 | return Status::OK(); |
| 34 | } |
| 35 | const auto& any_assets = assets_it->second.any_list().value(); |
| 36 | for (const auto& any_asset : any_assets) { |
| 37 | AssetFileDef asset_file_def; |
| 38 | TF_RETURN_IF_ERROR( |
| 39 | ParseAny(any_asset, &asset_file_def, "tensorflow.AssetFileDef")); |
| 40 | asset_file_defs->push_back(asset_file_def); |
| 41 | } |
| 42 | return Status::OK(); |
| 43 | } |
| 44 | |
| 45 | void AddAssetsTensorsToInputs(const StringPiece export_dir, |
| 46 | const std::vector<AssetFileDef>& asset_file_defs, |