I have seen several example using GradientDescentOptimizer. Here is a good one
Tensorflow GradientDescentOptimizer example
The model in the above example is :
y_model = tf.multiply(x, w[0]) + w[1]
Do we provide tensorflow the gradient function? How does it know how to calculate the gradient?