|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | import logging
|
| 16 | +from concurrent.futures import ThreadPoolExecutor |
16 | 17 | from functools import partial
|
17 | 18 |
|
18 | 19 | from deepsparse import Pipeline
|
@@ -73,12 +74,30 @@ def _add_endpoint(
|
73 | 74 | endpoint_config: EndpointConfig,
|
74 | 75 | ):
|
75 | 76 | pipeline_config = endpoint_config.to_pipeline_config()
|
76 |
| - pipeline_config.kwargs["executor"] = self.executor |
77 | 77 |
|
78 | 78 | _LOGGER.info(f"Initializing pipeline for '{endpoint_config.name}'")
|
79 |
| - pipeline = Pipeline.from_config( |
80 |
| - pipeline_config, context=self.context, logger=self.server_logger |
81 |
| - ) |
| 79 | + if pipeline_config.kwargs.get("continuous_batch_sizes"): |
| 80 | + pipeline_config.kwargs["executor"] = ThreadPoolExecutor( |
| 81 | + max_workers=self.server_config.num_workers |
| 82 | + ) |
| 83 | + _LOGGER.info( |
| 84 | + "for continuous batching, the single stream scheduler will be enabled." |
| 85 | + ) |
| 86 | + pipeline_config.num_cores = self.server_config.num_cores |
| 87 | + pipeline_config.scheduler = "single" |
| 88 | + |
| 89 | + pipeline = Pipeline.from_config( |
| 90 | + pipeline_config, |
| 91 | + num_streams=self.server_config.num_workers, |
| 92 | + logger=self.server_logger, |
| 93 | + ) |
| 94 | + else: |
| 95 | + pipeline_config.kwargs["executor"] = ThreadPoolExecutor( |
| 96 | + max_workers=self.context.num_streams |
| 97 | + ) |
| 98 | + pipeline = Pipeline.from_config( |
| 99 | + pipeline_config, context=self.context, logger=self.server_logger |
| 100 | + ) |
82 | 101 |
|
83 | 102 | _LOGGER.info(f"Adding endpoints for '{endpoint_config.name}'")
|
84 | 103 | self._add_inference_endpoints(
|
|
0 commit comments