I’d like to make a circulant matrix from a given vector of dimension N in a way such that the operation and the resulting matrix consume only O(N) memory cost. Higher dimensional generalization of this operation is needed for a certain variant of Transformer I’m trying to investigate. A naive approach is to apply ‘expand’ to the original vector and then to apply ‘view’ and ‘slice’ alternately. However, this doesn’t work, as ‘view’ demands the input to be contiguous. Is there any viable way you can think of?