#1843·apex

ASP Automatic Sparsity forward function For Loop Error

Author: maro-jeonCreated Sep 6, 2024Updated Nov 23, 2025

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