Skip to content

Commit

Permalink
Allow for an individual pipeline to override which device it is place…
Browse files Browse the repository at this point in the history
…d on. Furthermore, this avoids a TypeError in the event someone tries to do that. First spotted in #1089
  • Loading branch information
AngledLuffa committed Mar 1, 2024
1 parent 17eb6fc commit 44058a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stanza/pipeline/multilingual.py
Expand Up @@ -134,13 +134,16 @@ def _update_pipeline_cache(self, lang):
logger.info("Not all requested processors %s available for %s. Loading %s instead", self.default_processors, lang, lang_processors)
lang_config['processors'] = ",".join(lang_processors)

if 'device' not in lang_config:
lang_config['device'] = self.device

# update pipeline cache
if lang not in self.pipeline_cache:
logger.debug("Loading unknown language in MultilingualPipeline: %s", lang)
# clear least recently used lang from pipeline cache
if len(self.pipeline_cache) == self.max_cache_size:
self.pipeline_cache.popitem(last=False)
self.pipeline_cache[lang] = Pipeline(dir=self.model_dir, device=self.device, **self.lang_configs[lang])
self.pipeline_cache[lang] = Pipeline(dir=self.model_dir, **self.lang_configs[lang])

def process(self, doc):
"""
Expand Down

0 comments on commit 44058a0

Please sign in to comment.