Static frameworks can infer the input size based on the computation graph.
I.e. if we know which activation will be passed to the linear layer in advance, we can set the number of input features based on the activation shape.
However, as the forward pass is not known in advance in PyTorch and the computation graph is dynamically created in each forward pass, we cannot pre-compute the input shape without losing the flexibility of a dynamic approach.
Anyway, a linear layer is basically a matrix multiplication and an addition. The matrix size has to be set before the actual forward pass takes place.