Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ppq使用torch_mlir导出tosa格式的mlir #557

Open
zccyman opened this issue Apr 30, 2024 · 1 comment
Open

ppq使用torch_mlir导出tosa格式的mlir #557

zccyman opened this issue Apr 30, 2024 · 1 comment

Comments

@zccyman
Copy link

zccyman commented Apr 30, 2024

def export_mlir(model, dummy_input):

    from torch_mlir import torchscript
    module = torchscript.compile(model, dummy_input, output_type="tosa")
    print("TOSA OutputType\n")
    with open(f"test.mlir", "wt") as f:
        print(module.operation.get_asm(), file=f)

if DEVICE == 'cuda':
    collate_fn = lambda x: x.cuda()
else:
    collate_fn = lambda x: x
   
output = executor.forward(inputs=collate_fn(dataset[0]))
export_mlir(
    executor, 
    collate_fn(dataset[0]),
)        

抛出了如下错误,该怎么解决呢?
Exception has occurred: RuntimeError

Unknown type name 'dict':
File "/home/congcong.zhang/.miniconda3/envs/torch-mlir/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 368
def forward(
self,
inputs: Union[dict, list, torch.Tensor],
~~~~ <--- HERE
output_names:List[str] = None,
hooks: Dict[str, RuntimeHook] = None
File "/home/congcong.zhang/workspace/code/ppq/ppq/samples/test_resnet18.py", line 30, in export_mlir
module = torchscript.compile(model, dummy_input, output_type="tosa")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/congcong.zhang/workspace/code/ppq/ppq/samples/test_resnet18.py", line 246, in
export_mlir(
RuntimeError:
Unknown type name 'dict':
File "/home/congcong.zhang/.miniconda3/envs/torch-mlir/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 368
def forward(
self,
inputs: Union[dict, list, torch.Tensor],
~~~~ <--- HERE
output_names:List[str] = None,
hooks: Dict[str, RuntimeHook] = None

@ZhangZhiPku
Copy link
Collaborator

你玩的挺花啊...PPQ有自己的推理引擎,你为啥要导出成mlir呢...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants