You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "hadoop2xu (via GitHub)" <gi...@apache.org> on 2023/02/28 08:45:34 UTC
[GitHub] [tvm] hadoop2xu opened a new issue, #14141: [Bug] 程序执行到 mod, params = relay.frontend.from_pytorch(script_model, shape_list) 报错
hadoop2xu opened a new issue, #14141:
URL: https://github.com/apache/tvm/issues/14141
想对pytorch 模型做推理, pytorch模型倒出代码如下:
import torch as torch
import torch.nn as nn
class LeNet(nn.Module):
def __init__(self):
super(LeNet, self).__init__()
layer1 = nn.Sequential()
layer1.add_module("conv1", nn.Conv2d(1, 6, 5))
layer1.add_module("pool", nn.MaxPool2d(2, 2))
self.layer1 = layer1
layer2 = nn.Sequential()
layer2.add_module("conv2", nn.Conv2d(6, 16, 5))
layer2.add_module("pool2", nn.MaxPool2d(2, 2))
self.layer2 = layer2
layer3 = nn.Sequential()
layer3.add_module("fc1", nn.Linear(16*5*5, 120))
layer3.add_module("fc2", nn.Linear(120, 84))
layer3.add_module("fc3", nn.Linear(84, 10))
self.layer3 = layer3
def forward(self, x):
x = self.layer1(x)
x = self.layer2(x)
x = x.view(x.size(0), -1)
x = self.layer3(x)
return x
y = torch.randn(1, 1, 32, 32)
model = LeNet()
jit_model = torch.jit.trace(model, y)
torch.jit.save(jit_model, "lenet_model.pth")
推理代码如下:
model = torch.jit.load("lenet_model.pth“).eval()
input_data = torch.rand([1, 1, 32, 32])
shape_list = [("input0", input_data)]
mod, params = relay.frontend.from_pytorch(module.model, shape_list)
执行报错如下:
File "/docker_workspace/baidu/xpu/kmis/tool/anyinfer/anyinfer_v2.0/anyinfer_python/x86_64/python/tvm/relay/frontend/pytorch.py", line 4259, in from_pytorch
_run_jit_passes(graph)
File "/docker_workspace/baidu/xpu/kmis/tool/anyinfer/anyinfer_v2.0/anyinfer_python/x86_64/python/tvm/relay/frontend/pytorch.py", line 3838, in _run_jit_passes
torch._C._jit_pass_inline(graph)
AttributeError: module 'torch._C' has no attribute '_jit_pass_inline'
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] masahi closed issue #14141: [Bug] 程序执行到 mod, params = relay.frontend.from_pytorch(script_model, shape_list) 报错
Posted by "masahi (via GitHub)" <gi...@apache.org>.
masahi closed issue #14141: [Bug] 程序执行到 mod, params = relay.frontend.from_pytorch(script_model, shape_list) 报错
URL: https://github.com/apache/tvm/issues/14141
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] masahi commented on issue #14141: [Bug] 程序执行到 mod, params = relay.frontend.from_pytorch(script_model, shape_list) 报错
Posted by "masahi (via GitHub)" <gi...@apache.org>.
masahi commented on issue #14141:
URL: https://github.com/apache/tvm/issues/14141#issuecomment-1447837345
Please write in English.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org