Roger Federer had to fight to reach the final of Indian Wells after a three set victory over Borna Coric.