Skip to content

[MLIR Python Bindings] - Multiple output operations numerical validation test #132873

Open
@rockysingh9431

Description

@rockysingh9431

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?

Activity

llvmbot

llvmbot commented on Mar 25, 2025

@llvmbot
Member

@llvm/issue-subscribers-mlir

Author: Rocky Singh (rockysingh9431)

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?

llvmbot

llvmbot commented on Mar 25, 2025

@llvmbot
Member

@llvm/issue-subscribers-mlir-python

Author: Rocky Singh (rockysingh9431)

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?

joker-eph

joker-eph commented on Mar 25, 2025

@joker-eph
Collaborator

I don't understand why you deleted the Discourse topic to create a bug? You' have better chance of having support on Discourse.
It's not clear to me that this is a clear bug report, and you don't provide a reproducer here which is gonna make it even harder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @joker-eph@EugeneZelenko@llvmbot@rockysingh9431

        Issue actions

          [MLIR Python Bindings] - Multiple output operations numerical validation test · Issue #132873 · llvm/llvm-project