Ver Fonte

modify npu models infer bug (#2474)

a31413510 há 1 ano atrás
pai
commit
e4e9a12535

+ 8 - 6
paddlex/inference/components/paddle_predictor/predictor.py

@@ -176,12 +176,14 @@ class BasePaddlePredictor(BaseComponent):
 
         config.set_cpu_math_library_num_threads(self.option.cpu_threads)
 
-        if not (self.option.device == "gpu" and self.option.run_mode.startswith("trt")):
-            if hasattr(config, "enable_new_ir"):
-                config.enable_new_ir(self.option.enable_new_ir)
-            if hasattr(config, "enable_new_executor"):
-                config.enable_new_executor()
-            if self.option.device in ("cpu", "gpu"):
+        if self.option.device in ("cpu", "gpu"):
+            if not (
+                self.option.device == "gpu" and self.option.run_mode.startswith("trt")
+            ):
+                if hasattr(config, "enable_new_ir"):
+                    config.enable_new_ir(self.option.enable_new_ir)
+                if hasattr(config, "enable_new_executor"):
+                    config.enable_new_executor()
                 config.set_optimization_level(3)
 
         for del_p in self.option.delete_pass: