From 13ea0dae56da410969a82839d82b1a8e17f6ad41 Mon Sep 17 00:00:00 2001 From: warrentdrew Date: Wed, 3 Jul 2024 21:14:27 +0800 Subject: [PATCH] fix npu inference --- paddlespeech/t2s/exps/inference.py | 2 +- paddlespeech/t2s/exps/syn_utils.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/paddlespeech/t2s/exps/inference.py b/paddlespeech/t2s/exps/inference.py index 8a526982..21d105ad 100644 --- a/paddlespeech/t2s/exps/inference.py +++ b/paddlespeech/t2s/exps/inference.py @@ -112,7 +112,7 @@ def parse_args(): parser.add_argument( "--device", default="gpu", - choices=["gpu", "cpu", "xpu"], + choices=["gpu", "cpu", "xpu", "npu"], help="Device selected for inference.", ) parser.add_argument('--cpu_threads', type=int, default=1) diff --git a/paddlespeech/t2s/exps/syn_utils.py b/paddlespeech/t2s/exps/syn_utils.py index 9a07df64..75b98f1e 100644 --- a/paddlespeech/t2s/exps/syn_utils.py +++ b/paddlespeech/t2s/exps/syn_utils.py @@ -591,7 +591,8 @@ def get_predictor( config = inference.Config( str(Path(model_dir) / model_file), str(Path(model_dir) / params_file)) - config.enable_memory_optim() + if device != "npu": + config.enable_memory_optim() config.switch_ir_optim(True) if device == "gpu": config.enable_use_gpu(100, device_id)