Pth2onnx couldn't export python method

/home/hx/anaconda3/envs/py38_TensorRT/bin/python /home/hx/TensorRT/Palette-infer-demo/Palette-Image-to-Image-Diffusion-Models-main/pth2onnx.py
/home/hx/anaconda3/envs/py38_TensorRT/lib/python3.8/site-packages/torch/nn/functional.py:2515: UserWarning: floordiv is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the ‘trunc’ function NOT ‘floor’). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode=‘trunc’), or for actual floor division, use torch.div(a, b, rounding_mode=‘floor’).
_verify_batch_size([input.size(0) * input.size(1) // num_groups, num_groups] + list(input.size()[2:]))
/home/hx/TensorRT/Palette-infer-demo/Palette-Image-to-Image-Diffusion-Models-main/models/guided_diffusion_modules/unet.py:271: UserWarning: floordiv is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the ‘trunc’ function NOT ‘floor’). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode=‘trunc’), or for actual floor division, use torch.div(a, b, rounding_mode=‘floor’).
ch = width // (3 * self.n_heads)
/home/hx/TensorRT/Palette-infer-demo/Palette-Image-to-Image-Diffusion-Models-main/models/guided_diffusion_modules/unet.py:273: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can’t record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
scale = 1 / math.sqrt(math.sqrt(ch))
/home/hx/anaconda3/envs/py38_TensorRT/lib/python3.8/site-packages/torch/onnx/utils.py:461: UserWarning: no signature found for <torch.ScriptMethod object at 0x7fe79c132720>, skipping _decide_input_format
warnings.warn(“%s, skipping _decide_input_format” % e)
Traceback (most recent call last):
File “/home/hx/TensorRT/Palette-infer-demo/Palette-Image-to-Image-Diffusion-Models-main/pth2onnx.py”, line 55, in
torch.onnx.export(unet_script, input, onnx_model, opset_version=13)
File “/home/hx/anaconda3/envs/py38_TensorRT/lib/python3.8/site-packages/torch/onnx/init.py”, line 350, in export
return utils.export(
File “/home/hx/anaconda3/envs/py38_TensorRT/lib/python3.8/site-packages/torch/onnx/utils.py”, line 163, in export
_export(
File “/home/hx/anaconda3/envs/py38_TensorRT/lib/python3.8/site-packages/torch/onnx/utils.py”, line 1074, in _export
graph, params_dict, torch_out = _model_to_graph(
File “/home/hx/anaconda3/envs/py38_TensorRT/lib/python3.8/site-packages/torch/onnx/utils.py”, line 727, in _model_to_graph
graph, params, torch_out, module = _create_jit_graph(model, args)
File “/home/hx/anaconda3/envs/py38_TensorRT/lib/python3.8/site-packages/torch/onnx/utils.py”, line 582, in _create_jit_graph
module, params = _C._jit_onnx_list_model_parameters(freezed_m)
RuntimeError:
Couldn’t export Python method.:

The error message did not indicate which operator is incompatible, and I am unable to locate the specific error location.

The problem has been resolved, Couldn’t export Python method The areas that indicate incompatibility do not belong to modules, but rather to Python methods. My model uses the checkpoint function in Python to save memory and accelerate, while onnx does not support checkpoint function acceleration.