CoreML 工具:运行时错误:未实现操作“隐式”的 PyTorch 转换函数

问题描述 投票:0回答:1

我正在尝试

coremltools.converters.convert
追踪 PyTorch 模型,但出现错误:
PyTorch convert function for op 'intimplicit' not implemented

我正在尝试从 github 转换 RVC 模型。

我用

torch.jit.trace
追踪模型,CoreML 转换失败。所以我将有问题的部分追溯到WN层: 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 WN

model = WN(192, 5, dilation_rate=1, n_layers=16, gin_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])

我收到错误

RuntimeError: PyTorch convert function for op 'intimplicit' not implemented.

如何修改

WN::forward
,使其不生成
intimplicit
运算符,以便 CoreML 转换可以继续进行?

谢谢

大卫

python pytorch coreml
1个回答
0
投票

我终于找到了这个问题的根源。

模型正在调用具有

@torch.jit.script
装饰器的函数: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/infer/lib/infer_pack/commons.py#L108

删除这个装饰器,

torch.jit.trace
不再在跟踪中添加
intimplicit
运算符,CoreML工具可以成功转换模型。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.