我对 torchscript 和 JIT 比较陌生,并且收到此错误:
raise NotSupportedError(ctx_range, _vararg_kwarg_err)
torch.jit.frontend.NotSupportedError: Compiled functions can't take variable number of arguments or use keyword-only arguments with defaults:
File "/home/anushka/airborne-detection-starter-kit/seg_tracker/models_transformation.py", line 60
def updated_forward(*args, **kwargs):
~~~~~~~ <--- HERE
a = (tsm(args[0], duration=duration, dilation=dilation), ) + args[1:]
return orig_forward(*a, **kwargs)
这是我的转发函数,它采用 args 和 kwargs 参数。任何人都可以帮助我在没有错误的情况下传递这些论点
def add_tsm_to_module(obj, duration, dilation=1):
orig_forward = obj.forward
def updated_forward(*args, **kwargs):
a = (tsm(args[0], duration=duration, dilation=dilation), ) + args[1:]
return orig_forward(*a, **kwargs)
obj.forward = updated_forward
return obj