They are the same in my example but could be different.
With the same O, if my loss is: loss = 2*O[0] + 3*O[1] + 4*O[2] + 5*O[3] + 6*O[4]
Then the gradients of O wrt the loss would be [2, 3, 4, 5, 6] and the gradient of W [9, 5, 6].