So early on, as in the Lotus Sutra, Avalokitesvara / Guanyin was already predisposed to a change gender.
In Chinese art, Avalokitesvara was originally depicted as male.
In Chinese popular culture, however, compassion was imagined as a more obviously female trait, and so Guanyin became a kind of mother goddess of compassion by the 12th century.