During training process, my console is swamped by Warning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied.
I tried a few variants of
warnings.filterwarnings(
"once",
message="Constant folding not applied",
)
in both util.py
and train.py
, to no effect.
Digging through the code, I have traced a lot of those warnigs to torch._C._jit_pass_onnx_graph_shape_type_inference(graph, params_dict, _export_onnx_opset_version)
on line 252 of C:\Users\Dzenan\miniconda3\envs\deep_learning\Lib\site-packages\torch\onnx\utils.py
. My PyTorch Version is 1.11.0. I assume that torch._C
calls C or C++ code (Python debugger does not step into it). Maybe origination in C/C++ code makes those warnings funky, so they don’t get the same treatment as other Python warnings?
I invoke it via:
torch.onnx.export(
model,
dummy_input,
model_path,
export_params=True,
opset_version=11,
do_constant_folding=False,
input_names=["input"],
output_names=["output"],
dynamic_axes={"input": {0: "batch_size"}, "output": {0: "batch_size"}},
)
Stack trace and locals at line 252:
Does anyone have a suggestion?