Description
error log | 日志或报错信息 | ログ
malloc(): unsorted double linked list corrupted
Aborted (core dumped)
context | 编译/运行环境 | バックグラウンド
WSL/Ubuntu 24.04
Google Colab均复现
how to reproduce | 复现步骤 | 再現方法
1. 用pnnx转换模型
`from transformers import MobileViTImageProcessor, MobileViTForSemanticSegmentation
import torch
import pnnx
model = MobileViTForSemanticSegmentation.from_pretrained("apple/deeplabv3-mobilevit-xx-small")
model.eval() # 设置为评估模式
class CustomMobileViT(MobileViTForSemanticSegmentation):
def forward(self, input):
output = super().forward(input)
return output.logits # 只返回 logits 部分
custom_model = CustomMobileViT.from_pretrained("apple/deeplabv3-mobilevit-xx-small")
custom_model.eval()
x = torch.rand(1, 3, 512, 512)
opt_model = pnnx.export(custom_model, "deeplabv3_mobilevit_xx_small.pt", x)
print(opt_model)`
2. 使用生成的测试代码直接运行模型
`import numpy as np
import ncnn
import torch
def test_inference():
torch.manual_seed(0)
in0 = torch.rand(1, 3, 512, 512, dtype=torch.float)
out = []
with ncnn.Net() as net:
net.load_param("deeplabv3_mobilevit_xx_small.ncnn.param")
net.load_model("deeplabv3_mobilevit_xx_small.ncnn.bin")
with net.create_extractor() as ex:
ex.input("in0", ncnn.Mat(in0.squeeze(0).numpy()).clone())
_, out0 = ex.extract("out0")
out.append(torch.from_numpy(np.array(out0)).unsqueeze(0))
if len(out) == 1:
return out[0]
else:
return tuple(out)
if name == "main":
print(test_inference())
`