pytorch / TensorRT

PyTorch/TorchScript/FX compiler for NVIDIA GPUs using TensorRT
https://pytorch.org/TensorRT
BSD 3-Clause "New" or "Revised" License
2.6k stars 351 forks source link

🐛 [Bug] "Cannot convert symbols to int" when compiling graph that outputs tensor with dynamic shape #3269

Closed dgcnz closed 3 weeks ago

dgcnz commented 3 weeks ago

Bug Description

When doing parse_graph_io on a graph that outputs a tensor with dynamic shapes, extract_var_range_info(node.meta["val"]) fails because tensor.shape[0] in opt_val = int(tensor.shape[0].node.shape_env.get(expr) is an unbacked SymInt without an actual value attached.

This sort of makes sense, so I'm not sure if it's a bug or a non-feature.

Anyway, (I think) another possible source to get a value for that unbacked symint is to use tensor.shape[0].node.shape_env.dim_constraints._static_results which returns {"L['x'].size()[0] == 10"}.

To Reproduce

MRE and logs in this gist.

Expected behavior

Not sure.

Environment

Build information about Torch-TensorRT can be found by turning on debug messages