Last active
January 24, 2022 17:46
-
-
Save Lyken17/917be96d8a88765d52392533012866d3 to your computer and use it in GitHub Desktop.
test mbv2 numerical issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import torchvision | |
from torchvision import models | |
import numpy as np | |
import tvm | |
from tvm import relay | |
from tvm.contrib import graph_executor | |
model = models.mobilenet_v2(pretrained=True) | |
model = model.eval() | |
bs = 1 | |
rs = 224 | |
input_shape = [bs, 3, rs, rs] | |
input_data = torch.randn(input_shape) | |
scripted_model = torch.jit.trace(model, input_data).eval() | |
input_name = "input0" | |
shape_list = [(input_name, input_data.shape)] | |
mod, params = relay.frontend.from_pytorch(scripted_model, shape_list, use_parser_friendly_name=True) | |
# How to append a softmax after obtaining the mod? | |
# target = tvm.target.Target("llvm", host="llvm") | |
target = "llvm" | |
with tvm.transform.PassContext(opt_level=3): | |
lib = relay.build(mod, target=target, params=params) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment