Args: config (PredictConfig): the config to use. input_source (InputSource): the feedfree InputSource to use. Must match the signature of the tower function in config.
(self, config, input_source)
| 17 | """ |
| 18 | |
| 19 | def __init__(self, config, input_source): |
| 20 | """ |
| 21 | Args: |
| 22 | config (PredictConfig): the config to use. |
| 23 | input_source (InputSource): the feedfree InputSource to use. |
| 24 | Must match the signature of the tower function in config. |
| 25 | """ |
| 26 | self._config = config |
| 27 | self._input_source = input_source |
| 28 | assert config.return_input is False, \ |
| 29 | "return_input is not supported in FeedfreePredictor! " \ |
| 30 | "If you need to fetch inputs, add the names to the output_names!" |
| 31 | |
| 32 | self._hooks = [] |
| 33 | self.graph = config._maybe_create_graph() |
| 34 | with self.graph.as_default(): |
| 35 | self._input_callbacks = Callbacks( |
| 36 | self._input_source.setup(config.input_signature)) |
| 37 | with PredictTowerContext(''): |
| 38 | self._input_tensors = self._input_source.get_input_tensors() |
| 39 | config.tower_func(*self._input_tensors) |
| 40 | self._tower_handle = config.tower_func.towers[-1] |
| 41 | |
| 42 | self._output_tensors = self._tower_handle.get_tensors(config.output_names) |
| 43 | |
| 44 | self._input_callbacks.setup_graph(None) |
| 45 | |
| 46 | for h in self._input_callbacks.get_hooks(): |
| 47 | self._register_hook(h) |
| 48 | self._initialize_session() |
| 49 | |
| 50 | def _register_hook(self, hook): |
| 51 | """ |
nothing calls this directly
no test coverage detected