As pointed out by @Sinclair-Dee in
https://github.com/llvm/llvm-project/issues/62304, the tosa-to-linalg
conversion ignored the encoding attribute.
Also, this patch avoids an assertion error crash on unranked tensors.
Instead, the conversion now throws a "failed to legalize" error.
Fixes #62304 and fixes #63165.
If you dyn_cast that means we expect that this conversion can fail, so it should be checked. Otherwise if we know by construction that this can't fail we should cast.