In this paper, we compare Krull dimension, Gorenstein injective dimension and injective dimension of a module in several cases. In fact, we establish some generalizations of the Bass formula. To this end, we generalize the Grothendieck non-vanishing theorem to a class of modules larger than finitely generated modules.