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

how to convert model to torchscript? #382

Open
zhuziying opened this issue Nov 13, 2022 · 0 comments
Open

how to convert model to torchscript? #382

zhuziying opened this issue Nov 13, 2022 · 0 comments

Comments

@zhuziying
Copy link

zhuziying commented Nov 13, 2022

import sys
sys.path.insert(1,'/root/Downloads/ParallelWaveGAN-0.5.3/parallel_wavegan/utils')
import torch
import utils
module = utils.load_model('pretrained_model/checkpoint-400000steps.pkl')
print(module)
#model = torch.load('pretrained_model/checkpoint-400000steps.pkl',map_location=torch.device('cpu'))
#print('load model successful!')
x = torch.zeros(5, 10, 5, dtype=torch.float64)
x = x + (0.1**0.5)*torch.randn(5, 10, 5)
c = torch.rand(80,80,5)
print(x)
print('-------------------')
print(c)
print('-------------------')
print(x.size(-1))
print('-------------------')
print(c.size(-1))
trace_model = torch.jit.trace(module,(x,c))

error is :
Traceback (most recent call last):
File "demo.py", line 19, in
trace_model = torch.jit.trace(module,(x,c))
File "/root/anaconda3/envs/pwgan/lib/python3.7/site-packages/torch/jit/_trace.py", line 768, in trace
_module_class,
File "/root/anaconda3/envs/pwgan/lib/python3.7/site-packages/torch/jit/_trace.py", line 983, in trace_module
argument_names,
File "/root/anaconda3/envs/pwgan/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/anaconda3/envs/pwgan/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1178, in _slow_forward
result = self.forward(*input, **kwargs)
File "/root/Downloads/ParallelWaveGAN-0.5.3/parallel_wavegan/models/parallel_wavegan.py", line 159, in forward
assert c.size(-1) == x.size(-1)
AssertionError

how to set parametr x and c value?

@zhuziying zhuziying changed the title how to set x and c by pytorch.jit.trace function how to convert model to torchscript? Nov 13, 2022
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

1 participant