How do I calculate the partial derivative with respect to $x$?
While this may not be the answer you were looking for, I hope this explanation will help you to understand applying backpropagation to a CNN. Fundamentally, convolutional layers are no different than dense layers, however there are restrictions. The key one is weight-sharing which allows a CNN to be much more efficient than a regular dense layer (as well as it being sparse due to locality). Imagine we are transforming a 4x4 image into a 2x2 image. Since we are inputting a 16-vector, and outputting a 4-vector, we need a weights matrix of 4x16:



This has 64 parameters. In a convolutional layer, we can accomplish this by convolving a 3x3 kernel over the image:

$$ K=
\begin{bmatrix}
k_{1,1} &amp; k_{1,2} &amp; k_{1,3} \\
k_{2,1} &amp; k_{2,2} &amp; k_{2,3} \\
k_{3,1} &amp; k_{3,2} &amp; k_{3,3}
\end{bmatrix} $$

This convolution is equivalent to multiplying by the weights matrix:



As you can see, this only requires 9 parameters and backpropagation can be applied to update these parameters.

Image Source: https://towardsdatascience.com/intuitively-understanding-convolutions-for-deep-learning-1f6f42faee1