While exploring a torch.jit.trace() of the standard ResNet50 from torchvision.models I stumbled upon a peculiar structure at the very end of the network:
       <...>
         |
 ________v_________        ________             _________
|                  |      |        |           |         |
| aten::avg_pool2d |      | Int(0) |           | Int(-1) |
|__________________|      |________|           |_________|
         |                    |                     |
         |               _____v______     __________v__________
         |              |            |   |                     |
         |--------------> aten::size |---> prim::ListConstruct |
         |              |____________|   |_____________________|
         |                                          |
         |               ____________               |
         |              |            |              |
         `--------------> aten::view <--------------'
                        |____________|
                              |
                              v             _________
                       #==============# <--|_weights_|
                       # aten::linear #     _________
                       #==============# <--|_biases__|


What exactly is it needed for?
Why cannot aten::avg_pool2d be plugged directly into aten::linear?
At the moment I`m not too well-versed in PyTorch — but in those ML frameworks I`m familiar with nothing prevents such direct connections between 2D Average Pooling and Inner Product.