NVIDIA / apex

A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch
BSD 3-Clause "New" or "Revised" License
8.42k stars 1.4k forks source link

ASP Automatic Sparsity forward function For Loop Error #1843

Open maro-jeon opened 2 months ago

maro-jeon commented 2 months ago

I am trying to apply the yolov8 model to ASP. The yolo model has a block called c2f, and the forward function of this block contains a for statement and a list function.

    def forward(self, x):
        """Forward pass through C2f layer."""
        y = list(self.cv1(x).chunk(2, 1))
        y.extend(m(y[-1]) for m in self.m)
        return self.cv2(torch.cat(y, 1))

Because of this, the error below occurs.

I don't know how to avoid this.

If you know, please let me know.

torch.fx.proxy.TraceError: Proxy object cannot be iterated. This can be attempted when the Proxy is used in a loop or as a *args or **kwargs function argument. See the torch.fx docs on pytorch.org for a more detailed explanation of what types of control flow can be traced, and check out the Proxy docstring for help troubleshooting Proxy iteration errors