Open WilliamGwok opened 2 weeks ago
用的是2.0.0版本的model assistant
@baorepo ➜ /workspaces/ModelAssistant (2.0.0) $ git diff
diff --git a/tools/export.py b/tools/export.py
index bf22eff..1673021 100644
--- a/tools/export.py
+++ b/tools/export.py
@@ -286,12 +286,28 @@ def get_exported_file_name_from_precision(args, precision, ext: str = '') -> str
)
+def convert_inputshape_to_cmd(input_shape):
+ """
+ Converts the input shape to a command-line argument string for pnnx.
+
+ Args:
+ input_shape (torch.Size or list): The input shape of the model.
+
+ Returns:
+ str: A command-line argument string representing the input shape.
+ """
+ if not isinstance(input_shape, (list, tuple)):
+ raise ValueError("Input shape must be a list or tuple")
+
+ cmd = "inputshape=" + ",".join(map(str, input_shape))
+ return cmd
+
+
def export_pnnx(args, model):
import os.path as osp
import sys
import pnnx
- from pnnx.wrapper import convert_inputshape_to_cmd
model.eval()
pnnx_bin_path = osp.join(osp.dirname(pnnx.__file__), 'bin')
@WilliamGwok 试一下
def export_pnnx(args, model): import os.path as osp import sys
无法找到正确的pnnx版本