This is almost entirely mechanical.
Looks good, a few nits.
Can you start a new comment block to separate this from Tensor Dialect Operations above?
Can we remove the reference to MemRef here?
Put this on the previous line?
nit: Spell out auto here.
nit: Can you just merge this if into the parent one?
These could just be in the same anonymous namespace.
Address River's comments.
Actually, ss != st is redundant. (this was the previous code). I simplified it.
LLVM coding standard is to keep them small as small as possible so that there is good locality of reference.
"Because of this, we have a simple guideline: make anonymous namespaces as small as possible, and only use them for class declarations. For example:"