What does _clear_cached_op() do?


#1

I’m reading source code of faster_rcnn in gluoncv, and I find a _clear_cached_op() method in class RCNN that is not documented.
I wonder what it does. Here are the code where _clear_cached_op() shows up.

def set_nms(self, nms_thresh=0.3, nms_topk=400, post_nms=100):
    """Set NMS parameters to the network.

    .. Note::
        If you are using hybrid mode, make sure you re-hybridize after calling
        ``set_nms``.

    Parameters
    ----------
    nms_thresh : float, default is 0.3.
        Non-maximum suppression threshold. You can speficy < 0 or > 1 to disable NMS.
    nms_topk : int, default is 400
        Apply NMS to top k detection results, use -1 to disable so that every Detection
         result is used in NMS.
    post_nms : int, default is 100
        Only return top `post_nms` detection results, the rest is discarded. The number is
        based on COCO dataset which has maximum 100 objects per image. You can adjust this
        number if expecting more objects. You can use -1 to return all detections.

    Returns
    -------
    None

    """
    self._clear_cached_op()
    self.nms_thresh = nms_thresh
    self.nms_topk = nms_topk
    self.post_nms = post_nms

#2

This is used for hybrid blocks, this clears the cached symbolic graph.
In this case, I assume that everytime you set the nms threshold, that will result in a different symbolic graph execution, so you need to clear it when you set the nms threaashold to a new value.