You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a PyTorch model calculates a mask using something like this:
mask=vals<mask_val
and uses it to index a Tensor like this:
vals[mask]
the Torch-TensorRT model effectively does this:
vals[mask.long()]
Replacing the mask indexing operation with torch.masked_select, e.g.:
torch.masked_select(vals, mask)
makes the Torch-TensorRT model work correctly.
While the incorrectly working code creates Tensors that have different shapes, a common use case for this kind of masking involves placing the Tensors into a different, fixed-size Tensor. As a result, the outputs of such a PyTorch model will wildly differ from its associated Torch-TensorRT model, but because the mask casting happens silently, it's difficult to debug. As far as I could tell, this behavior isn't mentioned in the documentation, and the only thing I could find when googling around about this issue was this GitHub discussion.
Either work the same as masking does in PyTorch or raise a warning or error if a mask operation is detected, and instruct the user to use masked_select.
Environment
Build information about Torch-TensorRT can be found by turning on debug messages
Torch-TensorRT Version (e.g. 1.0.0): 1.4.0
PyTorch Version (e.g. 1.0): 2.0.1+cu117
CPU Architecture: i7-12800H
OS (e.g., Linux): Linux
How you installed PyTorch (conda, pip, libtorch, source): pip
Build command you used (if compiling from source):
Are you using local sources or building from archives:
Python version: 3.10.10
CUDA version: 11.7
GPU models and configuration: GeForce RTX 3080 Ti
Any other relevant information:
Additional context
The text was updated successfully, but these errors were encountered:
We will have to look at the specific operation decomposition here but there are some limitations for TensorRT and boolean inputs where in certain places we cast to int in order for the input to be accepted.
Bug Description
When a PyTorch model calculates a mask using something like this:
and uses it to index a
Tensor
like this:the Torch-TensorRT model effectively does this:
Replacing the mask indexing operation with
torch.masked_select
, e.g.:makes the Torch-TensorRT model work correctly.
While the incorrectly working code creates
Tensor
s that have different shapes, a common use case for this kind of masking involves placing theTensor
s into a different, fixed-sizeTensor
. As a result, the outputs of such a PyTorch model will wildly differ from its associated Torch-TensorRT model, but because the mask casting happens silently, it's difficult to debug. As far as I could tell, this behavior isn't mentioned in the documentation, and the only thing I could find when googling around about this issue was this GitHub discussion.To Reproduce
Expected behavior
Either work the same as masking does in PyTorch or raise a warning or error if a mask operation is detected, and instruct the user to use
masked_select
.Environment
conda
,pip
,libtorch
, source):pip
Additional context
The text was updated successfully, but these errors were encountered: