[tosa] Legalize tfl.real and tfl.imag
@NatashaKnk for visibility given you are looking close to here. Hi, it looks like something failed CI, but because its an internal check I wasn't able to take a look: `Google internal checks FAILED for runs with create time 2023-02-20T18:50`, is there a way I can view more information about the error? I see a failure on tensorflow/compiler/mlir/tosa/tests:tfl-to-tosa-pipeline.mlir.test , could you check locally? Hmm they seem to be passing for me locally, even with the branch rebased on `e6177f7d` I'll check later but the error was around a non-integer/float type being queried from wrong attribute. Could you check with assertions enabled? (I think for this tool you could still build the debug version). Thanks @jpienaar, building in debug revealed the issue.. hoping its fixed now!
TOSA has no notion of complex datatypes, it represents a single complex input tensor using two floating point input tensors corresponding to the "real" and "imag" parts of the complex input. To maintain the correct mapping of these tensors during the legalization from TFL to TOSA, a complex tensor of shape [x, ..., y] is converted to a single floating point tensor of shape [x, ..., y, 2] where each resulting pair of values can be used to represent a complex value. This ensures a 1:1 mapping between TFL and TOSA input/output tensors.

This commit intends to demonstrate the legalization of operations with a complex input by legalizing tfl.real and tfl.imag ops. In doing so, the infrastructure for legalizing and removing complex types from the resulting TOSA graph is provided. During the legalization "unrealized_conversion_cast" operations are interted to account for the difference in representation of complex tensors in TFL and TOSA. These casts are later fully removed by the "strip-complex-types" pass. Later commits will show legalization of operations with a complex output.

Legalization of tfl.real and tfl.imag is completed by slicing the relevant dimension of the complex input tensor, given shape [x, ..., y, 2], and then reshaping the result.

Signed-off-by: Luke Hutton <luke.hutton@arm.com>