Options for calling ImportGraphDef().
| 56 | |
| 57 | // Options for calling ImportGraphDef(). |
| 58 | struct ImportGraphDefOptions { |
| 59 | ImportGraphDefOptions() |
| 60 | : uniquify_names(false), |
| 61 | uniquify_prefix(false), |
| 62 | skip_mapped_nodes(false), |
| 63 | validate_shape(true) {} |
| 64 | |
| 65 | // Name prefix to use for nodes imported from the GraphDef. For example, if |
| 66 | // prefix="animals" and GraphDef contains a node "bunny" then the node will be |
| 67 | // named "animals/bunny" in *g. Must not be already used as a node name or |
| 68 | // prefix in the graph. |
| 69 | string prefix; |
| 70 | |
| 71 | // If true, imported node names will be modified if their name already exists |
| 72 | // in the graph. If false, conflicting names will be treated as an error. Note |
| 73 | // that this option has no effect if `prefix` is specified, since `prefix` |
| 74 | // will guarantee all node names are unique. |
| 75 | bool uniquify_names; |
| 76 | |
| 77 | // If true, `prefix` will be modified if it already exists as a node name or |
| 78 | // prefix in the graph. If false, a conflicting prefix will be treated as an |
| 79 | // error. This option has no effect if `prefix` isn't specified. |
| 80 | bool uniquify_prefix; |
| 81 | |
| 82 | // Maps tensors in `gdef` to existing tensors in `g`. Inputs in `gdef` |
| 83 | // corresponding to `input_map` keys will be remapped to the nodes in `g` |
| 84 | // corresponding to the values. |
| 85 | // |
| 86 | // Keys should not include `prefix`, i.e., a key ID's name should be the name |
| 87 | // as it originally appears in `gdef`. |
| 88 | // |
| 89 | // If this is non-empty, ImportGraphDef must be called with the shape refiner |
| 90 | // used to create the existing nodes referenced in `input_map`. |
| 91 | // TODO(skyewm): can we remove this requirement? How do we access the original |
| 92 | // shape refiner? |
| 93 | std::map<SafeTensorId, SafeTensorId> input_map; |
| 94 | |
| 95 | // If true, nodes that will have all output edges removed because of |
| 96 | // overrides in `input_map` will not be imported. |
| 97 | bool skip_mapped_nodes; |
| 98 | |
| 99 | // The names of existing nodes in `g` that the imported graph should have |
| 100 | // control dependencies on. |
| 101 | // |
| 102 | // Note that to avoid creating many redundant control edges, ImportGraphDef() |
| 103 | // won't add control edges to nodes that will inherit the dependencies from |
| 104 | // other nodes in `gdef`. |
| 105 | std::vector<string> control_dependencies; |
| 106 | |
| 107 | // Tensors in `gdef` that will be returned via the ImportGraphDefResults |
| 108 | // output parameter of `ImportGraphDef()`. If this list is non-empty, the |
| 109 | // caller must pass a results object to `ImportGraphDef()`. The |
| 110 | // `return_tensors` field will be populated with the imported nodes in `g`. |
| 111 | // |
| 112 | // Entries should not include `prefix`, i.e., each ID's name should be the |
| 113 | // name as it originally appears in `gdef`. |
| 114 | // |
| 115 | // If this contains a tensor that's also being remapped via `input_map`, the |