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

Implement numpy array over CPU OrtValues on return values #20539

Merged
merged 10 commits into from
May 8, 2024

Conversation

yuslepukhin
Copy link
Member

Description

Create numpy arrays based on the native buffers of returned OrtValues.
Hold on to the OrtValue until the numpy array is garbage collected.

Motivation and Context

This saves cpu on tensor copies and addresses customer concerns.

@yuslepukhin yuslepukhin requested a review from edgchen1 May 2, 2024 00:57
@yuslepukhin yuslepukhin force-pushed the yuslepukhin/numpy_over_ortvalue branch from 3429155 to 5ec0907 Compare May 2, 2024 17:28
  we preserve the original behaviour. Adjust comments.
  Reserve space for py::list.
@yuslepukhin yuslepukhin marked this pull request as ready for review May 2, 2024 23:18
Copy link
Contributor

@baijumeswani baijumeswani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

baijumeswani
baijumeswani previously approved these changes May 6, 2024
edgchen1
edgchen1 previously approved these changes May 7, 2024
onnxruntime/python/onnxruntime_pybind_mlvalue.h Outdated Show resolved Hide resolved
onnxruntime/python/onnxruntime_pybind_mlvalue.h Outdated Show resolved Hide resolved
@yuslepukhin yuslepukhin merged commit 08ecf30 into main May 8, 2024
95 checks passed
@yuslepukhin yuslepukhin deleted the yuslepukhin/numpy_over_ortvalue branch May 8, 2024 17:56
poweiw pushed a commit to poweiw/onnxruntime that referenced this pull request Jun 25, 2024
…20539)

### Description
Create numpy arrays based on the native buffers of returned OrtValues.
Hold on to the OrtValue until the numpy array is garbage collected.

### Motivation and Context
This saves cpu on tensor copies and addresses customer concerns.
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