<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/132873>132873</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR Python Bindings] - Multiple output operations numerical validation test
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rockysingh9431
      </td>
    </tr>
</table>

<pre>
    I have implemented a VarMeanOp in MLIR that computes variance and mean as outputs. I have successfully lowered this operation to LLVM and am now testing it using MLIR Python bindings as part of the numerical validation process.

Problem:
When dealing with single-output operations, I can correctly validate the results using Python bindings by creating a memref and invoking the operation using ExecutionEngine.invoke(). This works by leveraging APIs such as:

```
get_ranked_memref_descriptor()
make_nd_memref_descriptor(rank, type)
```
However, for multi-output operations, I am encountering issues.

What I Have Tried:

I created two separate memref descriptors for the two outputs (variance and mean).
I attempted to pass these memrefs to engine.invoke() to capture both results.
Unfortunately, I am unable to retrieve the correct outputs when invoking the operation.

Single output (works correctly)

```
res_memref = make_nd_memref_descriptor(rank, element_type)
engine.invoke("single_output_op", input_memref, res_memref)
```
Multiple outputs (not working)

```
var_memref = make_nd_memref_descriptor(rank, element_type)
mean_memref = make_nd_memref_descriptor(rank, element_type)
engine.invoke("multi_output_op", var_memref, mean_memref,input_memref)
```
Unable to get the correct results
How can I correctly handle multiple outputs in ExecutionEngine.invoke() when testing multi-output operations in Python?
Is there a recommended approach to create and pass multiple memrefs for capturing multiple outputs?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VV1v6jgQ_TXmZVQUHKDwkIfe24suUqutdu_HIxqcIfHWsSPbgeXfr8YJHy29q5VWKyEhR_aZmTPnzGAIurJEhZh9ErPHEXaxdr7wTr0eg7ZVvZzmk9HWlcdiDTXuCXTTGmrIRioB4Qf6Z0L7WwvawvPT-neINUZQrmm7SAH26D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