RuntimeError: ONNX export failed: Couldn’t export Python operator qfn

Hi,
I’m trying to convert a pytorch model to onnx, but the conversion gives the following error:

RuntimeError: ONNX export failed: Couldn’t export Python operator qfn

The definition for qfn is:

class qfn(torch.autograd.Function):
@staticmethod
def forward(ctx, input, k):
n = float(2**k - 1)
out = torch.round(input * n) / n
return out

@staticmethod
def backward(ctx, grad_output):
    grad_input = grad_output.clone()
    return grad_input, None

qfn_tmp = qfn.apply