Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PyExecutionSessionBase.cpp to get right result #3040

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fairytale0828
Copy link

@fairytale0828 fairytale0828 commented Jan 10, 2025

When I use pyruntime, the output tensor always contains the same element. I think this is because the pointer is not modified by the stride when getting the address. The pointer should move by the stride each time an element is read.

When I use pyruntime, the output tensor always contains the same element. I believe this is because the pointer is not modified by the stride when getting the address. The pointer should move by the stride each time an element is read.

Signed-off-by: Haoxiang Meng <[email protected]>
@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

@fairytale0828
Copy link
Author

微信截图_20250110134825

@chentong319
Copy link
Collaborator

When the computed output result with type OMTensor is converted to py::array in PyExecutionSessionBase.cpp, the stride is not used.

    outputPyArrays.emplace_back(
        py::array(dtype, shape, omTensorGetDataPtr(omt)));

There are two ways to identify whether the error is in PyExecutionSeesionBase.cpp, or somewhere else:

  1. Add omTensorPrint to print the generated OMTensor.
  2. Use the c driver, instead of the python driver. You can find the instructions at the beginning of file utils/RunONNXLib.cpp.
    I copy paste the instructions here: (replace test/backend/test_add/test_add.so with your .so)
cd onnx-mlir/build
sh ../utils/build-run-onnx-lib.sh test/backend/test_add/test_add.so

  On linux you run with:

Debug/bin/run-onnx-lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants