How to do linear indexing and what is the formula?

Yes, I mean, it’s something deterministic and ordered. You may want to have a look to this.

It’s really linked to how many dimensions does each dimension has.
Think that it works in a “FIFO” way. the 1st element of B will be also the 1st element taken for C.
So in the end A–>C is same than A–>B–>C if you don’t modify the ordering of the elements in B.

Lastly think that, since it’s ordered, it respects spatial structure. What does this mean?
Imagine you have a tensor
A (2,5,7,7)
You reshape it as
A’(52,1,7,7)
Then you apply a convolution and get
B’ (5
2,1,5,5)
if you reshape B back to
B ( 5,2,5,5)
The spatial structure of H and W remains since the ordering of the elements is equal to the ordering of A.