Open
Description
I was converting ultralytics/yolov5 from torch hub to executorch. Unfortunately one of the layers was unsupported, and the program exited with an error on this line: executorch_program: exir.ExecutorchProgramManager = edge_program.to_executorch()
. The traceback was:
I've looked into the file being exported and this is what I saw:
class BaseModel(nn.Module):
def _forward_once(self, x, p, v):
for m in self.model: # nn.Sequential
...
x = m(x) # run
...
return x
What is the recommended way to find out which layer in the nn.Sequential
failed?
Given that:
- Logging & printing is disabled
- Debugging with breakpoints doesn't work
I've ended up monkey-patching the model and unwinding the nn.Sequential by hand:
class DebugModel(nn.Module):
def forward(self, x):
x0 = self.model[0](x)
x1 = self.model[1](x0)
x2 = self.model[2](x1)
x3 = self.model[3](x2)
x4 = self.model[4](x3)
x5 = self.model[5](x4)
x6 = self.model[6](x5)
x7 = self.model[7](x6)
x8 = self.model[8](x7)
x9 = self.model[9](x8)
x10 = self.model[10](x9)
x11 = self.model[11](x10)
x12 = self.model[12]([x11, x6]) # [-1, 6],
x13 = self.model[13](x12)
x14 = self.model[14](x13)
x15 = self.model[15](x14)
x16 = self.model[16]([x15, x4]) # [-1, 4],
x17 = self.model[17](x16)
x18 = self.model[18](x17)
x19 = self.model[19]([x18, x14]) # [-1, 14],
x20 = self.model[20](x19)
x21 = self.model[21](x20)
x22 = self.model[22]([x21, x10]) # [-1, 10],
x23 = self.model[23](x22)
x24 = self.model[24]([x17, x20, x23]) # [17, 20, 23]
return x24
Executing this way I've found out that 11th layer is actually nn.Upsample which is unsupported. But my question is: Is there a better way? Is there a torch.export.log()
or something similar?