I am trying to coremltools.converters.convert
a traced PyTorch model and I got an error:
PyTorch convert function for op 'intimplicit' not implemented
I am trying to convert a RVC model from github.
I traced the model with torch.jit.trace
and it fails. So I traced down the problematic part to the ** layer : https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/infer/lib/infer_pack/modules.py#L188
import torch
import coremltools as ct
from infer.lib.infer_pack.modules import **
model = **(192, 5, dilation_rate=1, n_layers=16, ***_channels=256, p_dropout=0)
model.remove_weight_norm()
model.eval()
test_x = torch.rand(1, 192, 200)
test_x_mask = torch.rand(1, 1, 200)
test_g = torch.rand(1, 256, 1)
traced_model = torch.jit.trace(model,
(test_x, test_x_mask, test_g),
check_trace = True)
x = ct.TensorType(name='x', shape=test_x.shape)
x_mask = ct.TensorType(name='x_mask', shape=test_x_mask.shape)
g = ct.TensorType(name='g', shape=test_g.shape)
mlmodel = ct.converters.convert(traced_model,
inputs=[x, x_mask, g])
I got an error RuntimeError: PyTorch convert function for op 'intimplicit' not implemented.
How could I modify the **::forward
so it does not generate an intimplicit
operator ?
Thanks
David
I finally found the source of this issue.
Model is calling a function that has @torch.jit.script
decorator: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/infer/lib/infer_pack/commons.py#L108
Removing this decorator, torch.jit.trace
no longer add an intimplicit
operator in the trace and CoreML tools could succesfully convert the model.