Technically, the laws around rape, specifically those concerning the rape of married women, were extremely harsh.
Rape of a married woman was considered to be a great violation of the husband's rights, rather than the wife. This extended to an affront on the husband's family at large, since the wife was a part of his family and 'belonged' to the family.
The crime only gets worse if the wife suffered serious injury or death because of the rape.
For those accused and found guilty would almost certainly be sentenced to execution. The laws of Tokugawa Japan are notably strict and very austere, with local lords not often shying away from handing down judgments of capital punishment.
On the other hand, rape of an unmarried woman would be considered a lesser crime. Found guilty, this usually lead to either forced labor at various mines intended specifically for criminal laborers, or simply banishment.
Of course, many of these laws were not often practically applied to samurai or people of good standing if the victim was of a lower social standing. On the other hand, a samurai raping a woman of a samurai family would be in deep.
We should also recognize that many of the situations that we would call rape today would often not be recognized as rape in this time period in Japan. For example, a Edo Period Japanese husband wouldn't be raping his wife regardless of lack of consent, because she's his wife, of course! Examples from contemporary literature, even the famous Genji Monogatari (note, this was written many centuries prior to the 18th century), many of the 'romantic seductions' could very easily be construed as rape for a modern reader.
Assuming that a samurai was found guilty by a lord of rape and sentenced, he would likely not be sentenced to death but to a very lenient form of banishment, comparable to house arrest. On the list of worst crimes a samurai could commit, rape of a peasant women ranked very very low compared to treason, disobeying one's lord, illegally minting coins, etc.
And this is assuming the issue is brought up at all. While the image of a samurai being allowed to kill whoever they wanted with impunity in broad day light at a mere whim is a gross exaggeration, common people had good reason to not pick fights with their local samurai, who had a great deal of privilege and power over them as well as the advantage of having better connections to the people who ran the justice system.