Cannibalism is eating a monster of your own race. Generally speaking, this is a bad idea: you will gain the aggravate monster intrinsic and lose 2-5 points of Luck. If you are an orc or caveman though, cannibalism is considered natural for you and you will not be penalised.
If you are a dwarf, an elf, or a gnome, it should be clear which monsters are your own race, but if you are a human, it can be harder to tell. Anything represented by an @ sign that isn't obviously an elf is human. That includes werecreatures and doppelgangers but not Medusa, who should not be eaten for a different reason. Keystone Kops (anything represented by a K) also count as humans. Beware: a human character should not use blessed tins of nurse meat except in emergencies!
Eating a cat or dog is also frowned upon and will give you aggravate monster unless you are an orc or caveman. However, there is no taboo on eating horses or any other monster that was once your pet. (This is different from the rules for sacrificing where you may not sacrifice your own pet but may sacrifice a wild cat or dog.)
Cannibalism is not affected by polymorph. For example, a human player polymorphed into an orc-captain will still suffer the penalties for cannibalism when eating a human corpse (in addition to getting YAFM). The same human player polymorphed into an elf-lord will not suffer penalties for eating an elf corpse. However, digestion attacks are never considered cannibalism.