Finite and infinite dimensional generalizations of Klyachko's theorem