The ad must have discriminatory intent [1]. So if you're selecting candidates with a black box ML model and you didn't explicitly include racial/gender preferences...
But "the algorithm was sexist, not me" is probably going to be a losing argument in any court case.
[1] Well, not entirely, but that's another can of worms.