中文文檔
MNN安裝
MNN源碼:https://github.com/alibaba/MNN/tree/master/tools/converter
先安裝3.0以上版本的protobuf,再安裝,基本無坑。
簡單測試:
./backendTest.out ../benchmark/models/mobilenet-v1-1.0.mnn 10 0
./MNNConvert -h
模型轉換
tensorflow:
./MNNConvert -f TF/ONNX/TFLITE --modelFile XXX.pb/XXX.onnx/XXX.tflite --MNNModel XXX.XX --bizCode XXX
caffe:
./MNNConvert -f CAFFE --modelFile XXX.caffemodel --prototxt XXX.prototxt --MNNModel XXX.XX --bizCode XXX
pytorch:
import torch
import torchvision
dummy_input = torch.randn(10, 3, 224, 224, device='cuda')
model = torchvision.models.alexnet(pretrained=True).cuda()
input_names = [ "actual_input_1" ] + [ "learned_%d" % i for i in range(16) ]
output_names = [ "output1" ]
torch.onnx.export(model, dummy_input, "alexnet.onnx", verbose=True, input_names=input_names, output_names=output_names, do_constant_folding=True)
./MNNConvert -f ONNX --modelFile alexnet.onnx --MNNModel alexnet.mnn --bizCode MNN
MNN中NC4HW4格式
https://www.zhihu.com/question/337513515