zhang-prog преди 8 месеца
родител
ревизия
5c85d61688
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      libs/paddlex-hpi/src/paddlex_hpi/_config.py

+ 4 - 1
libs/paddlex-hpi/src/paddlex_hpi/_config.py

@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # See the License for the specific language governing permissions and
 # limitations under the License.
 # limitations under the License.
 
 
+import os
 import warnings
 import warnings
 from pathlib import Path
 from pathlib import Path
 from typing import Any, Dict, Literal, List, Mapping, Optional, Tuple, Type, Union
 from typing import Any, Dict, Literal, List, Mapping, Optional, Tuple, Type, Union
@@ -87,7 +88,9 @@ class TensorRTConfig(_BackendConfig):
         )
         )
         if self.precision == "FP16":
         if self.precision == "FP16":
             option.trt_option.enable_fp16 = True
             option.trt_option.enable_fp16 = True
-        if self.dynamic_shapes is not None:
+        if self.dynamic_shapes is not None and not os.path.exists(
+            option.trt_option.serialize_file
+        ):
             for name, shapes in self.dynamic_shapes.items():
             for name, shapes in self.dynamic_shapes.items():
                 option.trt_option.set_shape(name, *shapes)
                 option.trt_option.set_shape(name, *shapes)