Replies: 3 comments 1 reply
-
Why does the torch tracing even record this if condiftion? As the docs say
However when if print the
I can see, that it includes an if condition, which i suspect to be the if condition from the NMS code snippet above.
|
Beta Was this translation helpful? Give feedback.
-
@Tomakko I have the same doubts as you. The upstream torchvision team have refactored the from torchvision.ops import nms
@torch.jit._script_if_tracing
def batched_nms(
boxes: Tensor,
scores: Tensor,
idxs: Tensor,
iou_threshold: float,
) -> Tensor:
# Based on Detectron2 implementation, just manually call nms() on each class independently
keep_mask = torch.zeros_like(scores, dtype=torch.bool)
for class_id in torch.unique(idxs):
curr_indices = torch.where(idxs == class_id)[0]
curr_keep_indices = nms(boxes[curr_indices], scores[curr_indices], iou_threshold)
keep_mask[curr_indices[curr_keep_indices]] = True
keep_indices = torch.where(keep_mask)[0]
return keep_indices[scores[keep_indices].sort(descending=True)[1]] I haven't dig deeper on tvm recently, let me know if this works for you. |
Beta Was this translation helpful? Give feedback.
-
Just FYI, i endet up tracing and exporting the model without the postprocessing which included the problematic nms operations. WIth this approach, i was able to compile the model with tvm. |
Beta Was this translation helpful? Give feedback.
-
Hi @zhiqwang ,
i am still working on deploying the yolov5 rt model with TVM. It works out fine, when i use the VM compile
However i need to deploy it as a lib.so. Therefore i want to compile as
This runs into an error
TVMError: if is not supported.
Building this way does not support if statements in the graph
I am pretty sure this is caused by the if condition in
Do you have an idea how i can restructure the NMS avoiding this if statement?
All ideas are greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions