If all the non-zero $a_i$ are equal, the result is possibly true, providing that $f$ is defined so division by zero is not an issue.
But if any non-zero $a_i$ are unequal, the result is false. For instance, suppose $A\ne B$, both nonzero, and suppose $$f(x,y)=\frac{(A^2x^2 + B^2y^2)^2}{(A^3x^2+B^3y^2)(Ax^2+By^2)},$$ is convex. Then $f(1,y)$ would be a convex function of $y$. But one can check that $\lim_{y\to\pm\infty}f(1,y) = 1$, and that $f(1,0)=1$ as well. This implies $f(1,y)$ is the constant function $1$, and hence that $P(y)=(A^2+B^2y^2)^2 - (A^3+B^3y^2)(A+By^2) = 0$ for all $y$. This is a 4-th degree polynomial equation solved by all real $y$. Hence all the coefficients of $P$ vanish. The coefficient of $y^2$ in $P(y)$ is $2A^2B^2 - (A^3B + AB^3)$. This can only happen if $A=B$, contrary to hypothesis.