<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132872>132872</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Multi-Output Operations Numerical Validation in MLIR Python Bindings
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rockysingh-mcw
</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_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/eJy0VU1v4zYQ_TX0ZRBDoaw4Pujg_TBiIGmCdjd7NChqLLGmSIGk7PrfF0PKH7veLQoUBRwEFMg3b968mRHeq8Yglqz4wIpPEzGE1rrSWbk7emWa9q6Th0ll62O5hlbsEVTXa-zQBKxBwLtwLyjMaw_KwMvz-ncIrQggbdcPAT3shVPCSARhauhQGBAe7BD6IfgpjJB-kBK93w5aH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