It would be a mortal sin if you at any point gave full consent to these thoughts (I’m assuming we’re speaking of objectively grave matter here). It would be venial if you started to consent to them but caught yourself immediately. And it would be no sin at all if you rejected these thoughts from the start.
If you entertained these thoughts without realizing their moral character, but immediately stopped upon realizing that they were gravely sinful, you would not be guilty of mortal sin.