I’m trying to convert my PyTorch model to ONNX and after that to TensorRT and found out that there is no NonZero op for TensorRT
I found the part in my code that produces this operation and it is filtering tensors:
keep = (conf_scores > conf_thresh) sc = conf_scores[keep]
When I apply my mask keep (it contains 1 and 0) to my tensor this operation produces NonZero tensor when I execute
I tried to a little bit another code:
mask = conf_scores > conf_thresh indices = torch.nonzero(mask) sc = conf_scores[indices]
The result is the same.
How to filter tensor and not to produce NonZero operation when converting in onnx?
UPD: tried the other code:
mask = conf_scores > conf_thresh sc = torch.masked_select(conf_scores, mask)
and the other:
sc = conf_scores[conf_scores > conf_thresh]
and again there is NonZero op in ONNX