Build a diagonal matrix from a vector, or pull out the diagonal of a matrix.
In ML papers
diag(v) with a vector inside builds a diagonal matrix with v on the diagonal and zeros elsewhere; multiplying by it scales each coordinate, the same as v⊙. With a matrix inside, diag(A) usually means the vector of its diagonal entries. Diagonal covariances, N(μ,diag(σ2)), are everywhere in VAEs.