Is NonMaxSupression supported in the Tensorflow frontend?

Hi,

I have seen that NMS is supported in the relay IR but not in the tensorflow frontend.

What can be done to enable this operator in the tensorflow frontend?

Thanks

I also want to know.

The NMS seems to be supported in the Relay IR but not in the Tensorflow frontend. Unfortunately, there is no clear documentation on how to expose such relay operator in the frontends of TVM.

Could someone give a hint on how to address this?

Thanks

@tico, I am working on tf nms support, have a draft implementation here. Will pr it after a few fixes.

@tico tf nms usually works with TensorArray and Control Flow like Merge. We are actively working on enabling all of them. Then TF ssd, rcnn, fast-rcnn, faster-rcnn, mask-rcnn, yolo, etc. will be supported.

@yongwww it sounds great that you have already a draft of the TF nms support. Do you have an idea how long could it take to have in the master?. Is the PR already submitted? In the mean time I can of course check your branch.

Thanks!

@yongwww Is this draft ready to test?. Do you have an estimation when the PR will be submitted?

Thanks a lot

still need to fix an issue about index, I am working on something else. Will come back to this fix once I have some cycles.

Thanks, I am looking forward to it. I have been trying to test your branch any way but I hit an issue with a reshape operator described in [Tensorflow] object has no attribute 'name_hint', max_reduce and reshape, it would be nice if you can give me some hints on that as well.

Hi @yongwww? I was wondering whether you have any update on this? Have you merged (part of) your changes into main yet? Thanks for your time.

@yongwww Hi, I followed your pr and found it denied last month, seems it still needs some fix ? I downloaded the nms branch in your repo to run ssd model, but it failed to work with the log “There is no definition of tensor_array_float32”. any updates? thank you !

@derisavi Sorry was working on something else, I will work on the nms pr and try to make it merged. Currently it should be working well.

@sleepwalker2017 NMS was supported well now, the error you saw was from tensorflow converter and tensorarray specifically. We have fixed most of the issues and make TF ssd works locally, but need sometime to fix perf gap, will upstream the code gradually.

2 Likes

Hi @yongwww do you have any update on this? Thanks for your time and efforts.

The pr was merged, you can try it out

1 Like

Hi Yong,

I wonder if your team would be considering implementing the latest NMSv5 (in tensorflow called NonMaxSuppressionV5 for tensorflow frontend) or NonMaxSuppressionV5 for tflite frontend.

I stumbled upon this problem as the model I am trying optimise contains this NonMaxSuppressionV5. I tried to replace NonMaxSuppressionV5 with NonMaxSuppressionV3, the tensorflow frontend got through the parse stage and hit the problem

AttributeError: ‘<class ‘tvm.relay.expr.Call’>’ object has no attribute ‘name_hint’.

I posted the issue here

I wonder if it is possible to give some hints on implement a sophisticated operator, e.g.
NonMaxSuppression. I am trying to implement NonMaxSuppressionV5 for the tflite frontend.

Thanks in advance.

Is this NMS v5 added in tf2.x? Currently tvm tf frontend is for 1.x.

NMS5 is short for non_max_suppression_with_scores https://www.tensorflow.org/api_docs/python/tf/image/non_max_suppression_with_scores.

I have adapted non_max_suppression_with_scores with non_max_suppression, which can be parsed by the tensorflow frontend. However, I came across other issues

I am fully aware that the current tensorflow frontend only officially supports up to tf1.12.

As there is implementation of nms in relay, I would like to have some hints on implementing nms for tflite frontend, if it is possible.

Thanks.

@cam145 thanks for trying it out! Compared with nms, looks non_max_suppression_with_scores has extra parameter soft_nms_sigma, if you have added the support for soft_nms_sigma, welcome to send out a PR for this.

From the error message you shared, very likely the issue is frontend/relay related, you can try to identify which op introduces the op first.