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.
cast embeds an assertion already: the use of dyn_cast is intended for gracefully handling the result.