Ensures all input map values are tensors. This should be called from inside the import name scope. Args: name: the `name` argument passed to import_graph_def input_map: the `input_map` argument passed to import_graph_def. Returns: An possibly-updated version of `input_map`. R
(name, input_map)
| 176 | |
| 177 | |
| 178 | def _ConvertInputMapValues(name, input_map): |
| 179 | """Ensures all input map values are tensors. |
| 180 | |
| 181 | This should be called from inside the import name scope. |
| 182 | |
| 183 | Args: |
| 184 | name: the `name` argument passed to import_graph_def |
| 185 | input_map: the `input_map` argument passed to import_graph_def. |
| 186 | |
| 187 | Returns: |
| 188 | An possibly-updated version of `input_map`. |
| 189 | |
| 190 | Raises: |
| 191 | ValueError: if input map values cannot be converted due to empty name scope. |
| 192 | """ |
| 193 | if not all(isinstance(v, ops.Tensor) for v in input_map.values()): |
| 194 | if name == '': # pylint: disable=g-explicit-bool-comparison |
| 195 | raise ValueError( |
| 196 | 'tf.import_graph_def() requires a non-empty `name` if `input_map` ' |
| 197 | 'contains non-Tensor values. Try calling tf.convert_to_tensor() on ' |
| 198 | '`input_map` values before calling tf.import_graph_def().') |
| 199 | with ops.name_scope('_inputs'): |
| 200 | input_map = {k: ops.convert_to_tensor(v) for k, v in input_map.items()} |
| 201 | return input_map |
| 202 | |
| 203 | |
| 204 | def _PopulateTFImportGraphDefOptions(options, prefix, input_map, |
no test coverage detected